A lot of people don't understand the real role of Apache server or its benefits, so they usually rarely touch him in life or work, but in fact such servers are very useful, and testing and debugging are also necessary. of. Apache is the number one web server running on the Linux operating system. Many small places can be used to tune Apache's performance and reduce its impact on system resources. One of them is to adjust the memory usage. Of course, it may take some effort to achieve this goal.
For example, to determine the memory usage of an httpd thread via ps, you can enter the following command:
#ps-Uapache-uapacheu
USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND
apache130670.05.314970454504?SOct071:53/usr/sbin/httpd-f/etc/httpd/conf/httpd.conf-DAPACHE2
...
The output above It shows that a single httpd process uses 50MB of RSS (resident set size) memory (or non-switched physical memory) and 149MB of VSZ (virtual) memory. This of course depends to a large extent on the number of modules you load and run in Apache. This is by no means a fixed number. Since this number also contains shared library packages, it is not 100% accurate. We can think that half of the RSS number is the amount of memory actually used by the httpd thread, which may be a bit conservative, but it is very close to our purpose.
In this article, we assume that each httpd process is using 27MB of memory. Then, you need to determine the amount of memory that can be used by httpd. Depending on the other processes running on the machine, you may want to require 50% of the physical memory for Apache. On a system with 1GB of RAM, 512MB of memory can be divided into multiple 27MB of memory, which is about 19 concurrent httpd memories. Some people insist that each httpd thread "real" uses about 5MB of memory, so in theory you can divide 512MB of memory into 102 concurrent processes for Apache use (remember, unless your site Extremely huge traffic is required, otherwise this is very rare).
By default, Apache allocates up to 256 concurrent client connections, or 256 processes (one for each request). With this setup, a website with a lot of traffic will crash in an instant (even if you assume that each process occupies 5MB of memory, it will require 1.3GB of memory to satisfy the requested number). If no other action is taken, the system attempts to use the swap space through the hard disk to handle tasks that it cannot do in physical memory.
Other items that can be adjusted include KeepAlive, KeepAliveTimeout, and MaxKeepAliveRequests. The recommended settings that can be placed in the httpd.conf file are:
ServerLimit128MaxClients128KeepAliveOnKeepAliveTimeout2MaxKeepAliveRequests100
By reducing KeepAliveTimeout from 15 seconds to 2 seconds, you can increase the MaxClients command; 19 is too small, and 128 is better. many. By reducing the number of seconds the process survives, you can allow more connections in the same amount of time.
Of course, if there is no real test behind the back, the numbers are meaningless, and that's where the role of ab is. Use ab to adjust the Apache configuration file (MaxClients equals 256, ServerLimit equals 256, and KeepAliveTimeout equals 15) so that it can satisfy 1000 requests (100 consecutive requests are concurrently generated). (Be sure to have a terminal open on the server to observe the system load when performing the test.)
$ab-n1000-c100-k Now change the above server settings to a more conservative setting, restart Apache, try to test again (always from a remote computer, not the machine).
In the tests here, different settings caused the execution time to double the difference (27.8s and 16.8s, respectively), but the average load was 0.03 and 0.30. This may make your site a bit slower, but it will ensure that it does not crash under high load. Also keep in mind that you will need to do multiple tests to get an average.
Using ab is a great way to test your Apache configuration and it should be used every time you make a change that affects performance.
The methods of testing and debugging are introduced to you. I hope that you can really try it out, and there is a lot of knowledge about the server. You can find it when you usually can, and I hope it will help you.
Implementing copy and paste function in CMD command line and PowerShellFriends who often us
During the use of the computer, the blue screen problem is our most common problem. Recently, some u
In the case of very good network, IE cant open the webpage. It must be a headache for every user. Th
In the process of using the computer, it is inevitable that some problems will be encountered, such
Implement copy and paste function in CMD command line and PowerShell
GHOST blue screen of death and SATA hard drive suspended death solution
What is the process of ACS.exe? The role of the ACS.exe process
How to achieve remote automatic backup of Linux through scripts
Detailed technical explanation: U disk common fault repair method
Briefly introduce the functions of F1~F12 function keys
Sharing the secret of letting the system stop crashing
The browser prompts Internet Explorer to stop working. How to solve it?
How to view, modify, delete, and add environment variables in the cmd command line
Where is the path to the Win10 system magnifier tool?
Win7 system set everyone permissions method tutorial diagram
Maintenance and disassembly of server hardware system
Windows XP right click on "My Computer" does not show the solution for system properties
Win10 update Flash Player error 0x80070002 how to solve?
Win8 system to create application shortcuts on the desktop method
Win7 system open folder pop-up security warning how to solve?
Win8 system installation win7 graphics detailed
Win10 start menu and cortana Xiaona can't open how to do
Win7 system will scan the disk every time it starts and there will be a blue screen solution.