20 Linux server Performance tuning tips

Source: Internet
Author: User
Tags gpg gpg encryption ibm db2 syslog system log

Guide Linux is an open-source operating system, it supports a variety of hardware platforms, Linux server world-renowned, and it is the main difference between Windows is that the Linux server is generally not provided by default GUI (graphical user interface), but the command line interface, Its main purpose is to efficiently handle non-interactive processes, and response times are not so important, but it is critical to be able to handle high loads for long periods of time.

The Linux high Availability server cluster solution enables IT system administrators to handle many common hardware and software failures, allow multiple computers to work together, and provide protection for critical service uptime, and system administrators can perform maintenance and upgrades without disrupting service. Linux servers have various uses, such as Web servers or branch office internal servers, CMS or CRS servers, file servers (for Windows and/or Linux User Services), VoIP telephony servers, mail or domain name servers, database servers, Infrastructure nodes in cloud computing configuration. Linux is rich, powerful, and flexible, and you can do a variety of tasks with it, and in this article we'll discuss some tips for improving the performance of Linux servers.

1. Tuning the Linux kernel elevator algorithm for disk I/O

After selecting the file system, there are some kernel and mount options that may affect its performance, one of which is the elevator algorithm, which adjusts the elevator algorithm to balance low latency requirements and collect enough data to efficiently organize read and write requests to disk.

2. Disable unnecessary daemons, save memory and CPU resources

There are many daemons or services running on each server, and ironically, there are a lot of things that are not usually required, and these services do not work, but consume valuable memory and CPU time. In addition, they may put the server at risk, running a service more than a multi-directional hacker to open a straight door, so you should remove them from the server, the biggest advantage of disabling them is that it can speed up the startup time and free up memory. In addition, you can reduce the number of processes the CPU needs to process, and another benefit of disabling them is to enhance the security of the server, because fewer daemons mean fewer vulnerabilities to attack and exploit. Here are some of the Linux daemons that should be disabled, which are automatically run by default:

/tr> Td> 5
  Sequence number   ; daemon   Description
 1  apmd   Advanced Power Management Daemon
 2 nfslock for nfs file lock td>
 3 isdn isdn moderm support
 4 Autofs automatically mount file systems in the background (such as automatically mount CD-ROM)
Sendmail message transfer agent
 6 xfs x window font server
3. Turn off the GUI

In general, Linux servers do not require a GUI, and all administrative tasks can be done at the command line, so it is best to turn off the GUI, redirect the x display, or display it through a Web browser interface. In order to disable the GUI, "init level" should be set to 3 (command line login) instead of 5 (graphical login), and if GUI is required, you can run startx into the graphical user interface at any time.

4. Clean up unnecessary modules or functions

There are too many features or modules in the server package that are actually not needed (such as many of the features in Apache), carefully review the Apache configuration file, determine if FrontPage support or other additional modules are really needed, and if not, do not hesitate to disable them from the server. , which helps increase the amount of system memory available, freeing up more resources for the software that really needs it to run faster.

5. Disable the Control Panel

In Linux, there are a lot of popular control panels, such as cpanel,plesk,webmin and phpMyAdmin, I believe every Linux novice is very fond of these control panels, but disabling these packages can release about 120MB of memory, therefore, I strongly recommend disabling these control panels, and unless they really need to be used, they can be enabled via PHP scripts (albeit somewhat insecure), or command-line commands, so memory usage can be reduced by about 30-40%.

6. Improve Linux Exim server performance

There are many ways to improve server Exim performance, one way is to use the DNS cache daemon, which reduces the bandwidth and CPU time required to resolve DNS records, and the DNS cache improves network performance by eliminating the need to find DNS records every time from the root node, Djbdns is a very powerful DNS server with DNS caching capabilities, DJBDNS is more secure than the BIND DNS server, performs better, can be downloaded directly through http://cr.yp.to/, or is available through Red Hat packages.

7, using AES256 enhanced GPG file encryption security

In order to improve the security of backup files or sensitive information, many Linux system administrators will use GPG encryption, in the use of GPG, it is best to specify GPG using AES256 encryption algorithm, AES256 use 256-bit key, it is an open encryption algorithm, the United States National Security Agency (NSA) Use it to protect top-secret information, nothing is more secure than it.

8. Remote Backup service security

Security is the most important factor in choosing a remote backup service, and most system administrators are afraid of two things: (hackers) can delete backup files and not restore the system from backup. To ensure the security of backup files 100%, backup service companies provide remote backup servers, use SCP scripts or rsync to transfer data over SSH so that no one can access and access remote systems directly, so no one can delete data from the backup service. When choosing a remote backup service provider, it's a good idea to understand its service robustness in many ways, and if you can, you can test it yourself.

9. Update the default kernel parameter settings

To successfully and successfully run an enterprise application, such as a database server, you may need to update some of the default kernel parameter settings, for example, 2.4.x series kernel Message Queuing parameter Msgmni has a default value (for example, shared memory, or Shmmax in red The hat system has a default of only 33554432 bytes, it only allows limited database concurrent connections, and below provides some recommended values for better operation of the database server (from the IBM DB2 Support site): 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 across the WAN, and the longer the latency, the more TCP Linux size is recommended to increase the data transfer rate, and the TCP Linux size determines whether the sending host will not receive a data transfer acknowledgement How much data can be sent to the receiving host.

11. Select the correct file system

Using the Ext4 file system instead of the ext3 EXT4 is an enhanced version of the Ext3 file system, extending the storage limit it has logging capabilities to ensure high levels of data integrity (in abnormal shutdown events) it does not need to check the disk (this is a very time-consuming action) when it shuts down and restarts abnormally Faster write speed, EXT4 log optimizes drive head motion

12. Using the Noatime file system Mount option

Using the Noatime option in the File system boot profile fstab, this mount option can effectively improve performance if external storage is used.

13. Adjust Linux file descriptor limits

Linux limits the number of file descriptors that any process can open, with the default limit of 1024 per process, which may hinder benchmarking clients (such as Httperf and Apachebench) and the Web server itself from getting the best performance, with one process per connection for Apache, So it is not affected, but a single-process Web server, such as Zeus, uses one file descriptor per connection and is therefore susceptible to the default restrictions. Opening a file limit is a restriction that can be adjusted with the Ulimit command, the ulimit-as command displays the current limit, and the Ulimit-ah command displays a hard limit (you cannot increase the limit until the kernel parameters in/proc are not adjusted). Linux third-party application performance tips As with third-party applications running on Linux, there are many performance optimization techniques that can help you improve the performance of your Linux servers and reduce your operating costs.

14. Correct configuration of MySQL

To allocate more memory to MySQL, you can set the MySQL cache size, and if the MySQL server instance uses more memory, reduce the cache size and increase the MySQL cache if MySQL stalls when the request grows.

15. Proper configuration of Apache

Checking how much memory Apache uses, and then adjusting the startservers and minspareservers parameters to free up more memory, will help you save 30-40% of memory. tips for improving monitoring/troubleshooting capabilities Here are some tips to improve Linux server monitoring and troubleshooting:

16. Analyzing Linux Server Performance

The best way to improve system efficiency is to find the bottleneck that causes the overall speed drop and solve it, here are some basic tips for finding the system's key bottlenecks: When a large application, such as OpenOffice and Firefox, is running simultaneously, the computer may start to slow down and the chances of low memory are higher. If it is really slow to start, it may be that the initial startup of the application takes a long time to load, and it is normal to run once it is started, or the hard drive is probably too slow. CPU load continues to be high, memory is sufficient, but CPU utilization is low, and the load time can be monitored using the CPU load analysis tool.

17. Learn 5 Linux performance Commands

With a few commands you can manage the performance of your Linux system, listed below are 5 of the most common Linux performance commands, including Top, Vmstat, Iostat, free, and SAR, which help system administrators quickly resolve performance issues. (1) Top

The top command not only shows the tasks of the current kernel service, but also shows many statistics about the status of the host, which, by default, automatically updates the displayed data every 5 seconds (this interval is configurable), and through the top command, we can learn several results, such as: current uptime, system load, The number of processes and memory usage, in addition, this command also shows those processes that use the most CPU time (including various information for each process, such as running users, executing commands, etc.).

(2) Vmstat

The Vmstat command provides a snapshot of the current CPU, IO, process, and memory usage, which, like the top command, 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 run without any parameters, Iostat will display these three reports, using-c,- The D and-H parameters can display these three reports independently of each other.

(4) Free

The free command displays memory statistics for both main and swap spaces, specifying the-t parameter to display the total amount of memory, specifying that the-b parameter can be displayed in bytes, using-m in megabytes, and by default in kilobytes. The free command can also run continuously with the-s parameter plus a delay time (in seconds), such as: $ free-s 5

(5) SAR

The SAR command collects, views, and records performance data, which has a longer history than the previous commands, and it collects and displays longer periods of data.
18. Transfer log files to memory

When a machine is running, it is best to put the system log in memory, when the system shuts down and then copy it to the hard disk, when you run a syslog-enabled laptop or mobile device, Ramlog can help you improve the system battery or mobile device flash drive life, One of the benefits of using Ramlog is that there is no need to worry about a daemon sending a message to the syslog every 30 seconds, before the hard drive must be kept running, which is bad for hard drives and batteries.

19. Package First, then write

In memory to partition a fixed size of the space to save the log file, which means that the laptop hard drive does not have to keep running, only when a daemon needs to write to the log to run, note that the Ramlog use of memory space is fixed, otherwise the system memory will be used up quickly, if the notebook uses solid-state drive, 50-80MB memory can be allocated to ramlog use, Ramlog can reduce many write cycles, greatly improve the life of solid-state drives.

20, general tuning skills

Use static content instead of dynamic content whenever possible, and if you are generating weather forecasts or other data that must be updated every 1 hours, it is best to write a program that generates a static file every 1 hours instead of letting the user run a CGI to generate the report dynamically. Choosing the fastest and most suitable api,cgi for a dynamic application can be the easiest to program, but it will produce a process for each request, which is usually a costly and unnecessary process, fastcgi is a better choice, like Apache Mod_perl, Can greatly improve the performance of your application.

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

20 Linux server Performance tuning tips

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.