Linux server performance tuning skills, linux Server Tuning

Source: Internet
Author: User
Tags ibm db2 syslog domain name server

Linux server performance tuning skills, linux Server Tuning
Performance tuning skills for 20 Linux servers

Guide Linux is an open-source operating system that supports various hardware platforms. Linux servers are world-renowned. The main difference between Linux and Windows is that, by default, a Linux server does not provide a GUI (graphical user interface) but a command line interface. The main purpose of the GUI is to efficiently process non-interactive processes. The response time is not that important. On the contrary, it is critical to be able to process high loads for a long time.

The Linux high-availability server cluster solution allows IT system administrators to easily cope with many common hardware and software faults, and allows multiple computers to work together to ensure the normal operation of key services, the system administrator can perform maintenance and upgrade without interrupting services. Linux servers have various purposes, such as Web servers or internal branch servers, CMS or CRS servers, file servers (for Windows and/or Linux users), and VoIP telephone servers, email or Domain Name Server, database server, infrastructure node in cloud computing configuration, etc. Linux features are rich, powerful, and flexible. You can use it to complete various tasks. In this article, we will discuss some techniques to improve the performance of Linux servers.

1. Adjust the Linux kernel elevator Algorithm for disk I/O

After selecting a file system, some kernel and mount options may affect its performance. One of the kernel settings is the elevator algorithm. by adjusting the elevator algorithm, the system can balance low latency requirements, collect enough data to effectively organize read and write requests to the disk.

2. disable unnecessary daemon to save memory and CPU resources.

Many daemon or services are running on each server. The irony is that many of them are not usually necessary and do not play a role, however, it consumes valuable memory and CPU time. In addition, they may put servers in a dangerous situation. running one service is equivalent to opening a long drive-in door to multiple hackers. Therefore, you should remove them from the server, the biggest advantage of disabling them is that it can speed up the startup time and release the memory. In addition, you can reduce the number of processes that the CPU needs to process. Another advantage of disabling them is to enhance the security of the server, because the fewer daemon processes, the fewer vulnerabilities that can be attacked and exploited. The following are some Linux daemon that should be disabled. By default, they all run automatically:

Serial number Daemon Description
1 Apmd Advanced Power Management daemon
2 Nfslock Used to lock NFS files
3 Isdn Supported by ISDN Moderm
4 Autofs Automatic File System mounting in the background (such as automatic Mount CD-ROM)
5 Sendmail Email transmission proxy
6 Xfs X Window Font Server
3. Turn off the GUI

Generally, the Linux server does not require a GUI, and all management tasks can be completed under the command line. Therefore, it is best to turn off the GUI and redirect the X Display or display it through a Web browser interface. To Disable GUI, "init level (startup level)" should be set to 3 (command line logon), instead of 5 (graphical logon). If you need GUI, you can run startx at any time to enter the graphic user interface.

4. Clear unnecessary modules or functions

There are too many enabled functions or modules in the server software package that are not actually needed (for example, many functional modules in Apache). Check the Apache configuration file carefully, determine whether the FrontPage support or other additional modules are actually used. If you do not need it, do not hesitate to disable it from the server. This will help increase the system memory usage, free up more resources for the software that is really needed to make them run faster.

5. Disable Control Panel

In Linux, there are many popular control panels, such as Cpanel, Plesk, Webmin, and phpMyAdmin. I believe every beginner Linux user will like these control panels very much. However, disabling these software packages can free up to MB of memory, so I strongly recommend Disabling these control panels unless they are actually needed and they can be used through PHP scripts (although somewhat insecure ), or the command line command is enabled. After this is done, the memory usage can be reduced by about 30-40%.

6. improve Linux Exim server performance

There are many ways to improve the server's Exim performance, one of which is to use the DNS Cache daemon, which can reduce the bandwidth and CPU time required to parse DNS records, DNS Cache eliminates the need to search for DNS records from the root node each time to improve network performance. Djbdns is a very powerful DNS server with the DNS Cache function, djbdns is safer and better performing than the bind dns server. It can be obtained directly by downloading http://cr.yp.to/or using the software package provided by red Hat.

7. Use AES256 to enhance the security of gpg file encryption

To improve the security of backup files or sensitive information, many Linux system administrators use gpg for encryption. When using gpg, it is best to specify the gpg to use the AES256 encryption algorithm, and AES256 to use the 256-bit key, it is an open encryption algorithm, which is used by the National Security Agency (NSA) to protect top secret information. Nothing is safer than it.

8. Remote Backup Service Security

Security is the most important factor in choosing the remote backup service. Most system administrators are afraid of two things: (hackers) can delete Backup files and cannot recover the system from backup. To ensure the security of backup file 100%, the backup service company provides a remote backup server and uses scp script or RSYNC to transmit data through SSH. In this way, no one can directly access and access the remote system. Therefore, no one can delete data from the backup service. When selecting a remote backup service provider, it is best to learn about its service robustness from multiple aspects. If you can, you can test it yourself.

9. Update the default Kernel Parameter settings

To smoothly and successfully run enterprise applications, such as database servers, you may need to update some default Kernel Parameter settings. For example, the msgmni parameter of the 2.4.x series kernel message queue has a default value (for example, shared Memory, or shmmax is only 33554432 bytes by default on the Red Hat system), it only allows a limited number of concurrent connections to the database, the following provides some suggestions for better running of the database server (from the IBM DB2 support website): kernel. shmmax = 268435456 (32-bit) kernel. shmmax = 1073741824 (64-bit) kernel. msgmni = 1024 fs. file-max = 8192 kernel. sem = "250 32000 32 1024 ″

10. Optimize TCP

Optimizing the TCP protocol helps improve network throughput. The larger the bandwidth used for cross-Wan communication, the longer the delay time. We recommend that you use a larger TCP Linux size to increase the data transmission rate, the size of TCP Linux determines how much data can be sent to the receiving host when the sending host does not receive the data transmission confirmation.

11. Select the correct File System

Use ext4 file system to replace ext3 ● Ext4 is an enhanced version of ext3 file system, which extends storage restrictions ● it has the log function to ensure high-level data integrity (in abnormal shutdown events) ● during abnormal shutdown and restart, it does not need to check the disk (this is a very time-consuming action) ● faster write speed, ext4 logs optimize the Hard Disk Head action

12. Use the noatime File System mounting Option

Use the noatime option in the file system startup configuration file fstab. If external storage is used, this mount option can effectively improve performance.

13. Adjust Linux file descriptor restrictions

Linux limits the number of file descriptors that can be opened by any process. The default limit is 1024 per process. These restrictions may impede the benchmark test client (such as httperf and apache.pdf) and the Web server itself to obtain the best performance, each Apache connection uses a process, so it will not be affected, but a single process Web server, such as Zeus is a file descriptor for each connection, therefore, it is easy to be affected by the default limit. The file opening limit is a limit that can be adjusted using the ulimit command. The ulimit-aS command displays the current limit, and the ulimit-aH command displays the hard limit (before Kernel Parameters in proc are not adjusted, you cannot add restrictions ).Performance tips for third-party Linux applicationsThere are also many performance optimization skills for third-party applications running on Linux. These skills can help you improve the performance of Linux servers and reduce operating costs.

14. Correctly configure MySQL

To allocate more memory to MySQL, you can set the MySQL cache size. If the MySQL server instance uses more memory, the cache size will be reduced. If MySQL does not stop when the number of requests increases, add MySQL cache.

15. Configure Apache correctly

Check the memory used by Apache, and then adjust the StartServers and MinSpareServers parameters to release more memory, which will help you save 30-40% of the memory.Skills for improving monitoring/troubleshooting capabilitiesThe following are some tips for improving Linux Server monitoring and troubleshooting:

16. Analyze Linux server performance

The best way to improve system efficiency is to find the bottleneck that causes the overall speed drop and solve it. The following are some basic skills to find out the key bottlenecks of the system: ● when a large application program, for example, when OpenOffice and Firefox run at the same time, the computer may start to slow down and the memory insufficiency may increase. ● If the startup is really slow, it may take a long loading time for the application to start for the first time. Once the application is started, it will run normally. Otherwise, it is likely that the hard disk is too slow. ● High CPU load and sufficient memory, but low CPU utilization. You can use the CPU load analysis tool to monitor the load time.

17. Learn 5 Linux performance commands

You can use several commands to manage the Linux system performance. The following lists the five most commonly used Linux performance commands, including top, vmstat, iostat, free, and sar, they help system administrators quickly solve performance problems.(1) top

The Top command not only displays the tasks of the current kernel service, but also displays many statistics about the host status. By default, it automatically updates the displayed data every five seconds (this interval can be configured). Through the top Command, we can know several results, such as the current normal running time, system load, process count and memory usage. In addition, this command also displays the processes that use the most CPU time (including various information about each process, such as running users and executed commands ).

(2) vmstat

The Vmstat command provides snapshots of the current CPU, IO, process, and memory usage. It is similar to the top command and automatically updates data, such as: $ vmstat 10

(3) iostat

The Iostat command (included in the sysstat package on Ubuntu, Red Hat/Fedora) provides three reports: CPU utilization, device utilization, and Network File System utilization. When running without any parameters, iostat displays the three reports. The-c,-d, and-h parameters can be used to separately display the three reports.

(4) free

The Free command displays the memory statistics of the primary memory and swap space. The-t parameter can display the total memory count, and the-B parameter can be displayed in bytes, if-m is used, it is displayed in megabytes. By default, it is in kilobytes. You can use the-s parameter to add a delay time (unit: seconds) for continuous running of the Free command, for example, $ free-s 5.

(5) sar

The Sar command collects, views, and records performance data. This command has a longer history than the previous commands. It can collect and display long-period data.
18. transfer log files to memory

When a machine is running, it is best to store system logs in the memory and copy the logs to the hard disk when the system is disabled, when you run a laptop or mobile device with syslog enabled, ramlog can help you improve the life of your system battery or flash drive on your mobile device. One benefit of using ramlog is that, there is no need to worry that a daemon sends a message to syslog every 30 seconds. In the past, the hard disk must be running at any time, which is not good for hard disks and batteries.

19. Package and write

A fixed size of space is allocated in the memory to store log files, which means that the hard drive of the laptop does not need to keep running, and only runs when a daemon needs to write logs, note that the memory size used by ramlog is fixed. Otherwise, the system memory will soon be used up. If the laptop uses a solid state drive, 50-80 mb of memory can be allocated to ramlog, which can reduce many Write cycles, it greatly improves the service life of SSD.

20. General tuning skillsTry to use static content instead of dynamic content. If you are generating weather forecasts or other data that must be updated every other hour, you 'd better write a program to generate a static file every one hour, instead of letting the user run a CGI to dynamically generate a report. You can select the fastest and most appropriate API for a dynamic application. CGI may be the easiest to program, but it will generate a process for each request.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.