Talking about linux Performance Tuning 10: resource allocation planning talking about linux Performance Tuning 9: changing the system default limit http://www.bkjia.com/ OS /201307/228395.html we all understand the two working modes of apache, in this section, we will consider apache application configuration in prefork mode! First, let's talk about apache's prefork working mode: prefork: stable features, good support for dynamic pages! The working principle of prefork is that after the control process first establishes the "StartServers" sub-process, it creates a process to meet the needs of the "MinSpareServers" Settings. Wait for one second and create two more processes, wait a second to create four more ...... In this way, the number of Created processes is increased exponentially, up to 32 processes per second until the value set by MinSpareServers is met. This is the origin of prefork. This mode eliminates the need to generate new processes when requests arrive, thus reducing system overhead and increasing performance. MaxSpareServers sets the maximum number of idle processes. If the number of idle processes is greater than this value, apache automatically kill unnecessary processes. This value should not be too large, but if it is smaller than MinSpareServers, apache will automatically adjust it to MinSpareServers + 1. If the site load is large, consider increasing MinSpareServers and MaxSpareServers at the same time. MaxRequestsPerChild sets the number of requests that each sub-process can process. Each sub-process is automatically destroyed after processing "MaxRequestsPerChild" requests. 0 means that the sub-process will never be destroyed. Although the default value is 0, each sub-process can process more requests, setting it to a non-zero value also has two important advantages:. can prevent accidental Memory leakage; B. when the server load drops, the number of sub-processes is automatically reduced. Therefore, you can adjust this value based on the server load. But it cannot be too small. Otherwise, the system will continue to start new apache processes, resulting in a waste of resources. MaxClients is the most important of these commands. It sets the request that apache can process at the same time and is the parameter that has the greatest impact on apache performance. The default value of 150 is far from enough. If the total number of requests has reached this value (you can confirm it through ps-ef | grep http | wc-l), the subsequent requests will be queued, until a processed request is completed. This is the main reason why there are still a lot of system resources and http access is slow. The system administrator can dynamically adjust the value based on hardware configuration and load conditions. In theory, the larger the value, the more requests can be processed, but the default limit of apache cannot be greater than 256. If you set this value to greater than 256, apache cannot start. In fact, 256 is not enough for sites with a slightly higher load. ######################################## ########################## <IfModule prefork. c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 a server will never be here! MaxRequestsPerChild 4000 </IfModule> ################################## ################################# check the following data, I used AB for stress testing: AB-c 500-t 60 http: // 127.0.0.1/index.html to check the memory occupied by an apache process: see the top man documentation: note these columns o: VIRT -- Virtual Image (kb) The total amount of virtual memory used by the task. it includes des all code, data and shared libraries plus pages that have been swapped out. (Note: you can define the STATSIZE = 1 environment variable and the VIRT will be calculated from the/proc/#/state VmSize field .) VIRT = SWAP + RES. p: SWAP -- Swapped size (kb) The swapped out portion of a task's total virtual memory image. q: RES -- Resident size (kb) The non-swapped physical memory a task has used. in my opinion, swap can be manually added, while physical memory is the main limitation. We can see that AN httpd account for 3.3 M, and the MaxClients quantity can be calculated as follows: maxClients = (physical memory * 0.8-memory used for clean boot)/3.3 M (note that ServerLimit must be configured, and MaxClients must be smaller than ServerLimit) oracle is a database with memory consumption, when it is enabled, the upper G memory is allocated to the SGA, and several important internal memory areas can be manually adjusted. during planning, you must pay attention to the system security and memory usage, (For more information, see oracle architecture)