20 linux optimization tips


Linux is an open source operating system that supports various hardware platforms. Linux servers are well-known all over the world. The main difference between it and Windows is that Linux servers generally do not provide GUI (graphical user interface) by default, but command line Interface, its main purpose is to efficiently handle non-interactive processes, response time is not so important, on the contrary, being able to handle high loads for a long time is the most critical. The Linux high-availability server cluster solution allows IT system administrators to calmly deal with many common hardware and software failures, allowing multiple computers to work together to ensure the normal operation of critical services, and system administrators can perform maintenance and upgrades without interrupting services.
Linux servers are used for various purposes such as web servers or in-branch servers, CMS or CRS servers, file servers (for Windows and/or Linux users), VoIP telephony servers, mail or domain name servers, database servers, in cloud computing configurations infrastructure nodes, etc.
Linux is feature-rich, powerful, and flexible, and you can use it to accomplish a variety of tasks. In this article, we will discuss some tips to improve the performance of your Linux server.
1. Adjust the Linux kernel elevator algorithm for disk I/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 be balanced Low latency requirements, collecting enough data to efficiently organize read and write requests to disk.
2. Disabling unnecessary daemons saves memory and CPU resources
Every server has many daemons or services running on it, and ironically, many are usually not necessary, these services do not play a role, but consume valuable memory and CPU time. Also, they can put the server at risk, running one more service is the same as opening a door to hackers, so you should remove them from the server, the biggest benefit of disabling them is that it can speed up the startup time, release RAM. Also, you can reduce the number of processes the CPU needs to handle, another benefit of disabling them is to increase the security of the server, as fewer daemons mean fewer vulnerabilities that can be attacked and exploited.
Here are some Linux daemons that should be disabled. By default, they all run automatically:
Serial Number Daemon Description
1 Apmd Advanced Power Management Daemon
2 Nfslock for NFS File Locking
3 Isdn ISDN Modem Support
4 Autofs Automatically in the Background Mounting file systems (such as auto-mounting CD-ROMs)
5 Sendmail mail transfer agent
6 Xfs X Window font server
3. Turn off GUI
In general, Linux servers do not require GUI, and all administrative tasks can be performed on the command line is done, so it's 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), not 5 (graphical login). If GUI is required, you can always run startx to enter the GUI.
4. Clean up unwanted modules or features There are too many enabled features or modules
in the server package that are not actually needed (such as many feature modules in Apache), check the Apache configuration file carefully to determine whether FrontPage supports or other Whether the extra modules are really needed, and if not, they should be disabled from the server without hesitation. This will help increase system memory availability and free up more resources for those software that really need them to run well. faster.
5. Disable Control Panel
In Linux, there are many popular control panels, such as Cpanel, Plesk, Webmin and phpMyAdmin, etc. I believe that every Linux beginner will like these control panels, but disabling these packages can free up about 120MB of memory, so, I strongly recommend disabling these control panels unless they are really needed, they can be enabled via a PHP script (albeit somewhat unsafe), or a command line command, doing so reduces memory usage 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 resolve DNS records. The need to start looking up DNS records, thereby improving network performance, Djbdns is a very powerful DNS server, it has DNS caching capabilities, Djbdns is more secure than BIND DNS servers, and has better performance, and can be accessed directly through http://cr.yp. to/download, or through packages provided by Red Hat.
7. Use AES256 to enhance gpg file encryption security
In order to improve the security of backup files or sensitive information, many Linux system administrators will use gpg for encryption. When using gpg, it is best to specify gpg to use AES256 encryption algorithm, AES256 uses 256-bit key , it's an open encryption algorithm used by the NSA to protect top secret information, and nothing is more secure than it.
8. Security of remote backup services
Security is the most important factor in choosing a remote backup service. Most system administrators are afraid of two things: (hackers) can delete backup files and cannot restore the system from backups.
In order to ensure 100% security of the backup files, the backup service company provides a remote backup server, using scp scripts or RSYNC to transfer data over SSH, this way, no one can directly enter and access the remote system, therefore, no one can delete data from the backup service . When choosing a remote backup service provider, it's a good idea to understand the robustness of its service in several ways, and if you can, test it out for yourself.
9. Update the default kernel parameter settings
In order to run enterprise applications such as database servers smoothly and successfully, some default kernel parameter settings may need to be updated, for example, the 2.4.x series kernel message queue parameter msgmni has a default value (for example, shared memory , or shmmax is only 33554432 bytes by default on Red Hat systems), which only allows a limited number of concurrent connections to the database, here are some suggested values ​​for the database server to run better (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. Optimizing TCP
Optimizing TCP protocol helps to improve network throughput, The larger 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. How much data the host sends.
11. Choose the right file system
Use the ext4 file system instead of ext3
Ext4 is an enhanced version of the ext3 file system, extending storage limits
It has a journaling function to ensure a high level of data integrity (in the event of an abnormal shutdown)
In the event of an abnormal shutdown It doesn't need to check the disk when shutting down and restarting abnormally (this is a very time consuming action)
●Faster writing speed, ext4 journal optimizes hard disk head
motion
.
13. Adjust Linux File Descriptor Limits
Linux limits the number of file descriptors any process can open, the default limit is 1024 per process, these limits can hinder benchmarking clients (like httperf and apachebench) and the web server itself from getting the best out of it Performance, Apache uses one process per connection and so won't be affected, but single-process web servers such as Zeus use one file descriptor per connection and are therefore easily affected by 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 cannot increase the limit without adjusting the kernel parameters in /proc).
Linux third-party application performance tips
For running on Linux, there are many performance optimization tips that can help you improve the performance of your Linux server and reduce operating costs.
14. Configure MySQL correctly
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 MySQL stagnates when requests increase, increase the MySQL cache.
15. Correctly configure Apache
to check how much memory Apache uses, and then adjust the StartServers and MinSpareServers parameters to release more memory, which will help you save 30-40% of memory.
Tips for improving monitoring/troubleshooting skills
Here are some tips to improve Linux server monitoring and troubleshooting:
16. Analyze Linux server performance The best way to
improve system efficiency is to identify the bottlenecks that are causing the overall slowdown and fix them. Here are some basic tips for identifying key system bottlenecks :
● When large applications such as OpenOffice and Firefox are running at the same time, the computer may start to slow down and the chances of running out of memory are higher.
● If the startup is really slow, it may be that the application program takes a long time to load for the first time. Once it is started, it will run normally. Otherwise, the hard disk may be too slow.
●The CPU load is continuously high and the memory is sufficient, but the CPU utilization is very low. You can use the CPU load analysis tool to monitor the load time.
17. Learn 5 Linux Performance Commands You can manage the performance of your Linux system with just
a few commands. Below is a list of the 5 most commonly used Linux performance commands, including top, vmstat, iostat, free, and sar, which help your system Administrators quickly resolve performance issues.
(1) The top
Top command not only displays the tasks of the current kernel service, but also displays a lot of statistical data about the state of the host. By default, it automatically updates the displayed data every 5 seconds (this time interval is configurable) , through the top command, we can get several results, such as: current uptime, system load, number of processes and memory usage, in addition, this command also shows those processes that use the most CPU time (including each process's Various information such as running user, executed command, etc.).
(2) vmstat
The Vmstat command provides a snapshot of the current CPU, IO, process and memory usage. It is similar to the top command and automatically updates the 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 with no arguments, iostat will display these three report, the three reports can be displayed independently using the -c, -d and -h parameters, respectively.
(4) The free
Free command displays the memory statistics of main memory and swap space. Specifying the -t parameter can display the total amount of memory. Specifying the -b parameter can display it in bytes. Use -m to display it in megabytes. By default it is in kilobytes.
The Free command can also be run continuously using the -s parameter plus a delay time (unit: seconds), such as:
$ free -s 5
(5)
The Sar command collects, views and records performance data. This command has more history than the previous commands. Over time, it can collect and display data over a longer period of time.
Others
Here are some performance tips classified as other:
18. Move log files to memory
When a machine is running, it is best to keep the system log in memory and copy it to memory when the system shuts down. hard drive, when you run a laptop or mobile device with syslog turned on, ramlog can help you improve the life of your system battery or flash drive of your mobile device, one of the benefits of using ramlog is that you don't have to worry about a daemon every once in a while 30 seconds to send a message to syslog, in the past, the hard disk must keep running at all times, which is not good for the hard disk and the battery.
19. Pack first, then write
Divide a fixed-size space in the memory to save the log file, which means that the laptop hard disk does not need to keep running all the time. It only runs when a daemon needs to write the log. Note that the size of the memory space used by ramlog is fixed, otherwise The system memory will be used up quickly. If the notebook uses a solid-state drive, 50-80MB of memory can be allocated to the ramlog. The ramlog can reduce many write cycles and greatly improve the life of the solid-state drive.
20. General tuning skills Use static content instead of dynamic content
as much as 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 , instead of having the user run a CGI to generate the report dynamically.
Choose the fastest and most suitable API for dynamic applications, CGI may be the easiest to program, but it spawns a process for each request, usually, this is a costly and unnecessary process, FastCGI is a better choice , like Apache's mod_perl, can greatly improve application performance.


The original text comes from: http://www.l-ch.net

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326491145&siteId=291194637