


Summary: 20 Linux server performance tuning tips

#Linux is an open source operating system that supports various hardware platforms. Linux servers are world-famous. The main difference between it and Windows is that Linux servers generally do not provide GUI (graphical user interface) by default, but commands 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.
Linux high-availability server cluster solutions allow IT system administrators to cope with many common hardware and software failures, allowing multiple computers to work together , providing guarantee for the normal operation of key services, and system administrators can perform maintenance and upgrades without interrupting services.
Linux servers are used for various purposes such as web servers or internal branch servers, CMS or CRS servers, file servers (serving Windows and/or Linux users), VoIP phone servers, mail or domain name servers, databases Servers, infrastructure nodes, etc. in cloud computing configurations.
Linux is feature-rich, powerful, and flexible. You can use it to complete various tasks. In this article, we will discuss some tips for improving the performance of Linux servers.
##After selecting the 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 low performance. Latency requirements, collecting enough data to efficiently organize read and write requests to disk.
There are many daemons or services running on every server, and the irony is that there are many that are often not necessary and are not functioning but are consuming valuable memory and CPU time. . In addition, they may put the server at risk. Running one more service means opening more doors for hackers to get in. Therefore, 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 the server. Memory. Additionally, you can reduce the number of processes the CPU has to handle. Another benefit of disabling them is increased server security, as fewer daemons means fewer vulnerabilities that can be attacked and exploited.
The following are some Linux daemons that should be disabled. By default, they all run automatically:
Serial number Daemon process Description
1 Apmd Advanced power management daemon
2 Nfslock Used for NFS file locking
3 Isdn ISDN Moderm support
4 Autofs Automatically mount in the background File system (such as automatically mounting CD-ROM)
5 Sendmail Mail Transfer Agent
6 Xfs X Window's font server
## Generally speaking, Linux servers do not require a GUI. All management tasks can be completed from 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, the "init level" should be set to 3 (command line login), not 5 (graphical login). If a GUI is required, you can always run startx to enter the graphical user interface.
##In Linux, there are many popular control panels, such as Cpanel, Plesk, Webmin and phpMyAdmin, etc. I believe that every Linux junior user likes these control panels. However, disabling these software packages can release about 120MB Memory, therefore, I strongly recommend disabling these control panels unless they are really needed. They can be enabled through PHP scripts (although somewhat unsafe), or command line commands. After doing this, the memory usage can be reduced by about 30 -40%.
##There are many ways to improve the performance of your server Exim performance, one way is to use the DNS caching daemon, which can reduce the bandwidth and CPU time required to parse DNS records. DNS caching 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 performs better than BIND DNS server. It can be downloaded directly from http://cr.yp.to/, or obtained through the software package provided by Red Hat.
Security is the most important factor when choosing a remote backup service. Most system administrators are afraid of two things: (hackers) can delete backup files and cannot restore the system from backup.
In order to ensure 100% security of backup files, backup service companies provide remote backup servers that use scp scripts or RSYNC to transfer data via SSH. In this way, no one can enter and access the remote system directly, and therefore, no one can directly enter and access the remote system. Data can be deleted from the backup service. When choosing a remote backup service provider, it is best to understand the robustness of its service from multiple aspects and, if possible, test it yourself.
##In order to run enterprise applications smoothly and successfully, such as database servers, 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 (default is only 33554432 bytes on Red Hat systems), which only allows limited concurrent connections to the database. The following provides some recommended values for the database server to run better (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″
##Ext4 is an enhanced version of the ext3 file system, extending the storage limit
It has a logging function to ensure a high level of data integrity (in the event of abnormal shutdown)
In It does not need to check the disk during abnormal shutdown and restart (this is a very time-consuming action)
Faster writing speed, ext4 log optimization The hard disk head movement
Linux limits what any process can Number of open file descriptors. The default limit is 1024 per process. These limits may prevent optimal performance from benchmarking clients (such as httperf and apachebench) and the web server itself. Apache uses one process per connection and therefore is not affected by However, 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 displays the current limit, and the ulimit -aH command displays the hard limit (you cannot increase it before adjusting the kernel parameters in /proc limit).
Linux third-party application performance tips
There are also many performance optimization tips for third-party applications running on Linux, these Tips can help you improve the performance of your Linux server and reduce operating costs.
##The best way to improve system efficiency is Find the bottlenecks that are causing the overall slowdown and resolve them. Here are some basic tips for identifying critical bottlenecks in your system:
● When large applications like OpenOffice and Firefox are running at the same time, your computer may start to slow down. , the probability of insufficient memory is higher.
● If the startup is really slow, it may be that the application takes a long time to load for the first time. Once it starts, it will run normally. Otherwise, the hard disk may be too slow. In addition, search the public account programmer Xiaole's backend and reply "make money" to get a surprise gift package.
●The CPU load continues to be 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.
## Just use a few commands To manage the performance of Linux systems, the five most commonly used Linux performance commands are listed below, including top, vmstat, iostat, free and sar, which can help system administrators quickly solve performance problems.
01 topThe Top command not only displays the tasks of the current kernel service, but also displays many statistics about the host status. By default Under, it automatically updates the displayed data every 5 seconds (this time interval is configurable). Through the top command, we can know several results, such as: current uptime, system load, number of processes and memory usage rate, in addition, this command also displays those processes that use the most CPU time (including various information for each process, such as running user, executed commands, etc.).
02 vmstatThe Vmstat command provides a snapshot of the current CPU, IO, process and memory usage. It is similar to the top command and updates automatically. Data, such as:
03 iostat
Iostat command (included in the sysstat package on Ubuntu, Red Hat/Fedora) Three reports are provided: CPU utilization, device utilization and network file system utilization. When running without any parameters, iostat will display these three reports. Use the -c, -d and -h parameters to display these three reports independently. report.
04 free
#The Free command displays memory statistics of main memory and swap space. Specify the -t parameter to display the total memory amount. Specify The -b parameter can be displayed in bytes. Use -m to display 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
##05 sarThe Sar command collects, views and records performance data. This command has a longer history than the previous commands. It Longer period data can be collected and displayed.
OtherHere are some performance tips categorized as Other:
##When a machine is When running, it is best to keep 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 the syslog function turned on, ramlog can help you improve the system battery. Or the life of a mobile device flash drive. One benefit of using ramlog is that you no longer have to worry about a daemon sending a message to syslog every 30 seconds. In the past, the hard disk had to keep running at all times, which was not good for the hard disk and the battery. .
##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 to generate a static file every hour rather than letting the user run a CGI to dynamically generate the report.
Choose the fastest and most appropriate API for dynamic applications. CGI may be the easiest to program, but it will spawn a process for each request. Usually, this is a costly and unnecessary process. FastCGI is a better choice, and like Apache's mod_perl, can greatly improve application performance.
The above is the detailed content of Summary: 20 Linux server performance tuning tips. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

C language conditional compilation is a mechanism for selectively compiling code blocks based on compile-time conditions. The introductory methods include: using #if and #else directives to select code blocks based on conditions. Commonly used conditional expressions include STDC, _WIN32 and linux. Practical case: Print different messages according to the operating system. Use different data types according to the number of digits of the system. Different header files are supported according to the compiler. Conditional compilation enhances the portability and flexibility of the code, making it adaptable to compiler, operating system, and CPU architecture changes.

1.0.1 Preface This project (including code and comments) was recorded during my self-taught Rust. There may be inaccurate or unclear statements, please apologize. If you benefit from it, it's even better. 1.0.2 Why is RustRust reliable and efficient? Rust can replace C and C, with similar performance but higher security, and does not require frequent recompilation to check for errors like C and C. The main advantages include: memory security (preventing null pointers from dereferences, dangling pointers, and data contention). Thread-safe (make sure multi-threaded code is safe before execution). Avoid undefined behavior (e.g., array out of bounds, uninitialized variables, or access to freed memory). Rust provides modern language features such as generics

The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.

There are many reasons why MySQL startup fails, and it can be diagnosed by checking the error log. Common causes include port conflicts (check port occupancy and modify configuration), permission issues (check service running user permissions), configuration file errors (check parameter settings), data directory corruption (restore data or rebuild table space), InnoDB table space issues (check ibdata1 files), plug-in loading failure (check error log). When solving problems, you should analyze them based on the error log, find the root cause of the problem, and develop the habit of backing up data regularly to prevent and solve problems.

MySQL cannot run directly on Android, but it can be implemented indirectly by using the following methods: using the lightweight database SQLite, which is built on the Android system, does not require a separate server, and has a small resource usage, which is very suitable for mobile device applications. Remotely connect to the MySQL server and connect to the MySQL database on the remote server through the network for data reading and writing, but there are disadvantages such as strong network dependencies, security issues and server costs.

The C language function library is a toolbox containing various functions, which are organized in different library files. Adding a library requires specifying it through the compiler's command line options, for example, the GCC compiler uses the -l option followed by the abbreviation of the library name. If the library file is not under the default search path, you need to use the -L option to specify the library file path. Library can be divided into static libraries and dynamic libraries. Static libraries are directly linked to the program at compile time, while dynamic libraries are loaded at runtime.

The solution to MySQL installation error is: 1. Carefully check the system environment to ensure that the MySQL dependency library requirements are met. Different operating systems and version requirements are different; 2. Carefully read the error message and take corresponding measures according to prompts (such as missing library files or insufficient permissions), such as installing dependencies or using sudo commands; 3. If necessary, try to install the source code and carefully check the compilation log, but this requires a certain amount of Linux knowledge and experience. The key to ultimately solving the problem is to carefully check the system environment and error information, and refer to the official documents.
