Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of Linux performance tuning

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you what are the relevant knowledge points about the methods of Linux performance tuning, the content is detailed, and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

1. Adjust the Linux kernel elevator algorithm for disk Iram O

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

2. Disable unnecessary daemons to save memory and CPU resources

There are many daemons or services running on each server, and ironically, many are not usually necessary, and these services do not work, but consume valuable memory and CPU time. In addition, they may put the server in danger, and running one more service is tantamount to opening a long drive door to hackers, so you should remove them from the server. The biggest advantage of disabling them is that they can speed up startup time and free memory. In addition, you can reduce the number of processes that CPU needs to handle, and another benefit of disabling them is to enhance server security, because fewer daemons mean fewer vulnerabilities that can be exploited and exploited.

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

Serial number daemon description 1Apmd advanced power management daemon 2Nfslock for NFS file locking 3IsdnISDN Moderm support 4Autofs automatically mount file system (such as auto-mount CD-ROM) 5Sendmail mail transfer agent 6XfsX Window font server 3, turn off GUI

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

4. Clean up unwanted modules or functions

Too many features or modules that are started in the server package are actually not needed (such as many functional modules in Apache). Take a closer look at the Apache configuration file to determine whether FrontPage support or other additional modules are really needed, and if not, you should not hesitate to disable them from the server, which will help to increase the amount of memory available on the system and free up more resources for the software that is really needed. To make them run faster.

5. Disable the control panel

There are many popular dashboards in Linux, such as Cpanel,Plesk,Webmin and phpMyAdmin. I believe every beginner user of Linux likes these dashboards very much, but disabling these software packages can free up about 120MB memory, so I strongly recommend that you disable these dashboards unless they really need to be used, they can be enabled through PHP scripts (though somewhat unsafe) or command-line commands. Memory usage can be reduced by about 30-40%.

6. Improve the performance of Linux Exim server

There are many ways to improve the Exim performance of the server, 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 improves network performance by eliminating the need to look up DNS records from the root node every time. Djbdns is a very powerful DNS server with DNS caching function. Djbdns is more secure and better performance than BIND DNS server. You can download it directly through http://cr.yp.to/ or through the software package provided by Red Hat.

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

In order to improve the security of backup files or sensitive information, many Linux system administrators will use gpg encryption, when using gpg, it is best to specify gpg to use AES256 encryption algorithm, AES256 uses 256bit key, it is an open encryption algorithm, the United States National Security Agency (NSA) use it to protect top secret information, there is nothing 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 cannot restore the system from backup.

To ensure 100% security of backup files, backup service companies provide remote backup servers that use scp scripts or RSYNC to transfer data over SSH, so that no one can directly access and access the remote system, and therefore no one can delete data from the backup service. When choosing a remote backup service provider, it is best to understand the service robustness from multiple aspects, and if you can, you can test it yourself.

9. Update the default kernel parameter settings

In order to run enterprise applications, such as database servers, smoothly and successfully, you may need to update some default kernel parameter settings. For example, the 2.4.x series kernel message queue parameter msgmni has a default value (for example, shared memory, or shmmax defaults to only 33554432 bytes on Red Hat systems), which allows only limited concurrent database connections. Here are some suggested values (from the IBM DB2 support website) for the database server to run better:

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 to improve the network throughput. The greater the bandwidth used for communication across the WAN and the longer the delay time, it is recommended to use a larger TCP Linux size to improve the data transmission rate. The TCP Linux size determines how much data the sending host can send to the receiving host when it does not receive a data transmission acknowledgment.

11. Choose the correct file system

Replace ext3 with ext4 file system

● Ext4 is an enhanced version of the ext3 file system that extends storage limits

● has logging capabilities to ensure a high level of data integrity (in abnormal shutdown events)

When ● shuts down and restarts abnormally, it does not need to check the disk (this is a very time-consuming action)

● faster write speed, ext4 log optimizes hard disk head action

12. Use noatime file system mount option

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

13. Adjust the Linux file descriptor limit

Linux limits the number of file descriptors that any process can open, and the default limit is 1024 per process. These restrictions may prevent benchmark clients (such as httperf and apachebench) and the Web server itself from getting the best performance. Apache uses one process per connection, so it is not affected, but single-process Web servers, such as Zeus, use one file descriptor per connection, so they are vulnerable to the default limit.

The open file limit is a limit that can be adjusted with the ulimit command, the ulimit-aS command shows the current limit, and the ulimit-aH command shows the hard limit (you can't increase the limit until you adjust the kernel parameters in / proc).

Performance skills of Linux third-party applications

For third-party applications running on Linux, there are also many performance optimization techniques that can help you improve the performance of your Linux server and reduce running costs.

14. Configure MySQL correctly

To allocate more memory to MySQL, set the MySQL cache size, reduce the cache size if the MySQL server instance uses more memory, and increase the MySQL cache if MySQL stagnates as requests increase.

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% of your memory.

Skills to improve monitoring / troubleshooting capabilities

Here are some tips to improve Linux server monitoring and troubleshooting:

16. Analyze the performance of Linux server

The best way to improve the efficiency of the system is to identify the bottlenecks that lead to the overall speed decline and solve them. Here are some basic techniques for identifying the key bottlenecks of the system:

● when large applications, such as OpenOffice and Firefox, are running at the same time, the computer may start to slow down and run out of memory.

If ● is really slow to start, it may take a long time to load the application for the first time, and it will run normally once it is started, otherwise the hard drive is probably too slow.

● CPU has a sustained high load and sufficient memory, but CPU utilization is low, and you can use CPU load analysis tools to monitor load time.

17. Learn 5 Linux performance commands

You can manage the performance of your Linux system with a few commands. Here are the five most commonly used Linux performance commands, including top, vmstat, iostat, free, and sar, which help system administrators quickly resolve performance issues.

(1) top

The Top command shows not only the tasks of the current kernel service, but also a lot of statistics about the status of the host. By default, it automatically updates the displayed data every 5 seconds (this interval is configurable). Through the top command, we can know several results, such as current uptime, system load, number of processes and memory usage. This command also shows the processes that use the most CPU time (including various information about each process, such as running users, commands executed, etc.).

(2) vmstat

The Vmstat command provides a snapshot of the current CPU, IO, process, and memory usage, which 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 will display these three reports, which can be displayed independently using the-cmermerd and-h parameters.

(4) free

The Free command displays memory statistics for main memory and swap space, specify the-t parameter to display the total amount of memory, specify the-b parameter to display in bytes, and use-m to display in megabytes, which by default is 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, which collects, views, and records performance data, is older than the previous commands and can collect and display 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 and copy it to the hard disk when the system is shut down. When you run a laptop or mobile device with syslog enabled, ramlog can help you improve the life of the system's battery or mobile device flash drive. One advantage of using ramlog is that you no longer have to worry about a daemon sending a message to syslog every 30 seconds. The hard drive must be kept running at all times, which is bad for the hard drive and the battery.

19. Package first, then write

Set aside a fixed size of space in memory to save log files, which means that the laptop hard disk does not have to keep running all the time, but only when a daemon process needs to write to the log. Note that the memory space used by ramlog is fixed, otherwise the system memory will be quickly used up. If notebooks use solid state drives, 50-80MB memory can be allocated to ramlog, and ramlog can reduce many write cycles. The service life of solid state hard disk is greatly improved.

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 hour, it is best to write a program that generates a static file every hour, rather than having the user run a CGI to generate reports dynamically.

Choosing the fastest and most appropriate API,CGI for dynamic applications may be the easiest to program, but it generates a process for each request, which is usually a costly and unnecessary process, and FastCGI is a better choice, like Apache's mod_perl, which can greatly improve application performance.

These are all the contents of the article "what are the ways to tune Linux performance?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development