20 Linux server performance optimization techniques worth collecting _linux

Source: Internet
Author: User
Tags gpg ibm db2 memory usage mysql in syslog system log time interval

Linux is an open source operating system, it supports a variety of hardware platforms, Linux servers around the world, the main difference between it and Windows is that the Linux server by default generally does not provide a GUI (graphical user interface), but the command line interface, Its primary purpose is to efficiently handle non-interactive processes, and response times are not that important, and conversely, the ability to handle high loads over a long period of time is critical. The Linux high Availability server cluster solution allows IT system administrators to take care of many common hardware and software failures, allow multiple computers to work together, and provide security for critical services to function properly, and system administrators can perform maintenance and upgrades without disrupting services.

Linux servers are available for a variety of purposes, such as Web server 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 the cloud computing configuration.

Linux is rich, powerful, and flexible, and you can use it to accomplish a variety of tasks, and in this article we'll discuss some tips for improving the performance of Linux servers.

1. Adjust the Linux kernel elevator algorithm for disk I/O
after selecting the file system, some kernel and mount options may affect its performance performance, one of the kernel settings is the elevator algorithm, by adjusting the elevator algorithm, the system can balance the low latency requirements, collect enough data to effectively organize the disk read and write requests.

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 don't work, but they consume valuable memory and CPU time. In addition, they may put the server in jeopardy, running a service is tantamount to hacking open a door, so you should remove them from the server, disable them the most benefit is to speed up the boot time, free memory. In addition, you can reduce the number of processes the CPU needs to process, and the other benefit of disabling them is to enhance the security of the server, as fewer daemons mean fewer vulnerabilities to attack and exploit.

Here are some Linux daemons that should be disabled, which are automatically run by default:

3, turn off the GUI

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

4. Clean up unwanted modules or functions

There are too many features or modules in the server package that are actually not needed (such as many functional modules in Apache), look through the Apache configuration file, determine if FrontPage support or other additional modules are really needed, and if not, you should not hesitate to disable , which helps increase system memory availability, freeing up more resources for the software that really needs to run faster.

5. Disable Control Panel

In Linux, there are many popular control panels, such as cpanel,plesk,webmin and phpMyAdmin, believe that each Linux novice is very fond of these control panels, but, disable these packages can release about 120MB of memory, therefore, I strongly recommend disabling these control panels, unless they really need to be used, they can be done via PHP scripts (although some are unsafe), or command-line commands are enabled, so that the amount of memory usage can be reduced 30-40%.

6, improve the performance of Linux Exim server
There are a number of ways to improve server Exim performance by using the DNS cache daemon, which reduces the bandwidth and CPU time required to resolve DNS records, which 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 a BIND DNS server, has better performance, can be downloaded directly through http://cr.yp.to/ , or through a package provided by Red Hat.

7, using AES256 enhance GPG file encryption security

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

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 file 100%, the backup services company provides a remote backup server that uses SCP scripts or rsync to transmit data through SSH so that no one can access and access the remote system directly, so no one can delete the data from the backup service. When choosing a remote backup service provider, it is best to understand the robustness of its services in several ways, and if you can, test it yourself.

9. Update default kernel parameter settings

In order to run enterprise applications smoothly and successfully, such as the database server, some default kernel parameter settings may need to be updated, for example, the 2.4.x series kernel Message Queuing parameter Msgmni has a default value (for example, shared memory, or Shmmax in red With only 33554432 bytes on the hat system, which allows only limited database concurrent connections, the following provides some recommended values 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 increase network throughput, the greater the bandwidth that is used across the WAN, and the longer the latency, the greater the recommended TCP Linux size to improve the data transfer rate, and the TCP Linux size determines that the sending host does not receive data transfer confirmation How much data can be sent to the receiving host.

11, choose the right file system

Replace ext3 with Ext4 file system
EXT4 is an enhanced version of the Ext3 file system that extends storage limits
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) during an abnormal shutdown and reboot.
Faster write speed, EXT4 log optimizes drive head action

12. Use Noatime file system Mount option

Using the Noatime option in the file system startup profile Fstab, this mount option can effectively improve performance if external storage is used.

13, adjust the Linux file descriptor restrictions

Linux limits the number of file descriptors that any process can open, and the default limit is 1024 per process, which may hinder benchmark clients (such as Httperf and Apachebench) and the Web server itself from getting the best performance, using a single process for each of the Apache connections. Therefore, it is not affected, but a single process Web server, such as Zeus, uses a file descriptor per connection and is therefore susceptible to 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

For Third-party applications running on Linux, there are a number of performance optimization techniques that can help you improve the performance of your Linux servers and lower your operating costs.

14, the correct configuration of MySQL
in order to allocate more memory to MySQL, you can set the MySQL cache size, if the MySQL server instance uses more memory, reduce the cache size, if the MySQL in the request increase when the stall does not move, increase the MySQL cache.

15. Configure Apache correctly
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% memory.

Tips for improving monitoring/troubleshooting capabilities

Here are some tips for improving Linux server monitoring and troubleshooting:

16, analysis of Linux server performance
the best way to improve system efficiency is to find the bottleneck that leads to the overall rate of decline and solve it, and here are some basic techniques for identifying key bottlenecks in the system:
When large applications, such as OpenOffice and Firefox, run at the same time, the computer may start to slow down and have a higher likelihood of memory shortages.
If the startup is really slow, the application may be the initial start of a long time to load, once the boot is good to run after the normal, or very likely the hard drive is too slow.
CPU load continues to be high, memory is sufficient, but CPU utilization is low, and the CPU load analysis tool can be used to monitor load time.

17. Learn 5 Linux performance commands

With a few commands to manage the performance of your Linux system, the 5 most commonly used Linux performance commands, including Top, Vmstat, Iostat, free, and SAR, Help system administrators quickly resolve performance issues.
(1) Top
The top command shows not only the tasks of the current kernel service, also shows a lot of statistics about the state of the host, by default, it automatically updates the data displayed every 5 seconds (this time interval is configurable), through the top command, we can learn several results, such as: current uptime, system load, Number of processes and memory usage, in addition, this command shows the processes that use the most CPU time (including the various information for each process, such as running a user, executing a command, and so on).
(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, and when run without any parameters, Iostat displays the three reports, using-c,- The D and H parameters can be displayed independently of these three reports.
(4) Free
The free command displays memory statistics for primary and swap spaces, specifying the-t parameter to display the total amount of memory, specifying the-b parameter to be displayed in bytes, and using-m to display in megabytes, by default, in kilobytes.
The free command can also be run continuously using 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 can collect and display longer periods of data.

Other

Here are some of the other performance techniques categorized as:

18. Transfer log files to memory

When a machine is in operation, it is best to put the system log in memory and copy it to the hard disk when the system shuts down, and when you run a notebook or mobile device that has the syslog enabled, Ramlog can help you improve the life of your system battery or mobile device flash drive, One of the benefits of using Ramlog is that you don't have to worry about a daemon sending a message to syslog every 30 seconds, and that the hard drive must be kept running at all times, which is bad for both the hard drive and the battery.

19, first pack, then write

Partition a fixed size space in memory to save the log file, this means that the laptop hard drive does not have to keep running, only when a daemon needs to write to the log, note that ramlog use of the memory space is fixed, otherwise the system memory will soon be used up, if the notebook using solid-state hard drive, Can allocate 50-80MB memory to ramlog use, Ramlog can reduce many write cycles, greatly improve the life of solid-state hard disk.

20. General Tuning Skills

Use static content instead of dynamic content whenever possible, 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 dynamically generate the report.
Choosing the fastest and most appropriate api,cgi for a dynamic application may be the easiest to program, but it will produce a process for each request, usually a costly and unnecessary process, fastcgi is a better choice, like Apache Mod_perl, Can greatly improve the performance of your application.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.