Home Operation and Maintenance Linux Operation and Maintenance Summary: 20 Linux server performance tuning tips

Summary: 20 Linux server performance tuning tips

Aug 03, 2023 pm 03:22 PM
linux linux server


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.


01
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 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.


02
Disable unnecessary daemons


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

##03
Turn off the GUI

## 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.


##0
4##Clean up unnecessary modules or functions
There are too many enabled functions or modules in the server software package that are actually unnecessary (such as many function modules in Apache), Check the Apache configuration file carefully to determine whether FrontPage support or other additional modules are really needed. If not, you should disable them from the server without hesitation. This will help increase the amount of system memory available and free up more resources. Make the software that really needs it run faster.


##05
Disable Control Panel

##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%.


#06
Improvement Linux Exim Server Performance

##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.


##0
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 Use AES256 encryption algorithm. AES256 uses a 256-bit key. It is an open encryption algorithm. The National Security Agency (NSA) of the United States uses it to protect top-secret information. There is nothing more secure than it.


#08
Remote backup service security

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.


##09
Update default kernel parameter settings

##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″


##10
##Optimization TCP
# Optimizing the TCP protocol helps improve network throughput , the greater the bandwidth used for cross-WAN communication and the longer the delay time, it is recommended to use a larger TCP Linux size to increase the data transmission rate. The TCP Linux size determines how much the sending host can send to the host when it does not receive the data transmission confirmation. How much data the receiving host sends.




#11
Choose the correct file system


##Use ext4 file system instead of ext3




  • ##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



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



##13
Adjustment Linux file descriptor limits

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.


##14
##Correct Configure 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 MySQL becomes stagnant when requests increase, increase the MySQL cache.




#15
Configure Apache correctly
## Check how much memory Apache uses, and then adjust the StartServers and MinSpareServers parameters to free up more memory, which will help you save 30-40% of memory.
Here are some tips to improve Linux server monitoring and troubleshooting:



##16
Analysis Linux server performance

##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.



##17
Learn 5 Linux Performance Commands

## 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:




#$ vmstat 10


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:



##18
will Log files are moved to memory

##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. .


#19
Pack first, then write
Divide a fixed-size space in the memory to save the log file. This means that the laptop hard drive does not have to keep running. It only runs when a daemon needs to write the log. Pay attention to the memory space used by ramlog. The size 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 ramlog. Ramlog can reduce many write cycles and greatly improve the service life of the solid-state drive.



##20
General Tuning Tips

##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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Postman Integrated Application on CentOS Postman Integrated Application on CentOS May 19, 2025 pm 08:00 PM

Integrating Postman applications on CentOS can be achieved through a variety of methods. The following are the detailed steps and suggestions: Install Postman by downloading the installation package to download Postman's Linux version installation package: Visit Postman's official website and select the version suitable for Linux to download. Unzip the installation package: Use the following command to unzip the installation package to the specified directory, for example /opt: sudotar-xzfpostman-linux-x64-xx.xx.xx.tar.gz-C/opt Please note that "postman-linux-x64-xx.xx.xx.tar.gz" is replaced by the file name you actually downloaded. Create symbols

Detailed introduction to each directory of Linux and each directory (reprinted) Detailed introduction to each directory of Linux and each directory (reprinted) May 22, 2025 pm 07:54 PM

[Common Directory Description] Directory/bin stores binary executable files (ls, cat, mkdir, etc.), and common commands are generally here. /etc stores system management and configuration files/home stores all user files. The root directory of the user's home directory is the basis of the user's home directory. For example, the home directory of the user user is /home/user. You can use ~user to represent /usr to store system applications. The more important directory /usr/local Local system administrator software installation directory (install system-level applications). This is the largest directory, and almost all the applications and files to be used are in this directory. /usr/x11r6 Directory for storing x window/usr/bin Many

Where is the pycharm interpreter? Where is the pycharm interpreter? May 23, 2025 pm 10:09 PM

Setting the location of the interpreter in PyCharm can be achieved through the following steps: 1. Open PyCharm, click the "File" menu, and select "Settings" or "Preferences". 2. Find and click "Project:[Your Project Name]" and select "PythonInterpreter". 3. Click "AddInterpreter", select "SystemInterpreter", browse to the Python installation directory, select the Python executable file, and click "OK". When setting up the interpreter, you need to pay attention to path correctness, version compatibility and the use of the virtual environment to ensure the smooth operation of the project.

The difference between programming in Java and other languages ​​Analysis of the advantages of cross-platform features of Java The difference between programming in Java and other languages ​​Analysis of the advantages of cross-platform features of Java May 20, 2025 pm 08:21 PM

The main difference between Java and other programming languages ​​is its cross-platform feature of "writing at once, running everywhere". 1. The syntax of Java is close to C, but it removes pointer operations that are prone to errors, making it suitable for large enterprise applications. 2. Compared with Python, Java has more advantages in performance and large-scale data processing. The cross-platform advantage of Java stems from the Java virtual machine (JVM), which can run the same bytecode on different platforms, simplifying development and deployment, but be careful to avoid using platform-specific APIs to maintain cross-platformity.

MySQL installation tutorial teach you step by step the detailed steps for installing and configuration of mySQL step by step MySQL installation tutorial teach you step by step the detailed steps for installing and configuration of mySQL step by step May 23, 2025 am 06:09 AM

The installation and configuration of MySQL can be completed through the following steps: 1. Download the installation package suitable for the operating system from the official website. 2. Run the installer, select the "Developer Default" option and set the root user password. 3. After installation, configure environment variables to ensure that the bin directory of MySQL is in PATH. 4. When creating a user, follow the principle of minimum permissions and set a strong password. 5. Adjust the innodb_buffer_pool_size and max_connections parameters when optimizing performance. 6. Back up the database regularly and optimize query statements to improve performance.

Experience in participating in VSCode offline technology exchange activities Experience in participating in VSCode offline technology exchange activities May 29, 2025 pm 10:00 PM

I have a lot of experience in participating in VSCode offline technology exchange activities, and my main gains include sharing of plug-in development, practical demonstrations and communication with other developers. 1. Sharing of plug-in development: I learned how to use VSCode's plug-in API to improve development efficiency, such as automatic formatting and static analysis plug-ins. 2. Practical demonstration: I learned how to use VSCode for remote development and realized its flexibility and scalability. 3. Communicate with developers: I have obtained skills to optimize VSCode startup speed, such as reducing the number of plug-ins loaded at startup and managing the plug-in loading order. In short, this event has benefited me a lot and I highly recommend those who are interested in VSCode to participate.

How to limit user resources in Linux? How to configure ulimit? How to limit user resources in Linux? How to configure ulimit? May 29, 2025 pm 11:09 PM

Linux system restricts user resources through the ulimit command to prevent excessive use of resources. 1.ulimit is a built-in shell command that can limit the number of file descriptors (-n), memory size (-v), thread count (-u), etc., which are divided into soft limit (current effective value) and hard limit (maximum upper limit). 2. Use the ulimit command directly for temporary modification, such as ulimit-n2048, but it is only valid for the current session. 3. For permanent effect, you need to modify /etc/security/limits.conf and PAM configuration files, and add sessionrequiredpam_limits.so. 4. The systemd service needs to set Lim in the unit file

Comparison between Informix and MySQL on Linux Comparison between Informix and MySQL on Linux May 29, 2025 pm 11:21 PM

Informix and MySQL are both popular relational database management systems. They perform well in Linux environments and are widely used. The following is a comparison and analysis of the two on the Linux platform: Installing and configuring Informix: Deploying Informix on Linux requires downloading the corresponding installation files, and then completing the installation and configuration process according to the official documentation. MySQL: The installation process of MySQL is relatively simple, and can be easily installed through system package management tools (such as apt or yum), and there are a large number of tutorials and community support on the network for reference. Performance Informix: Informix has excellent performance and

See all articles