Linux performance optimization 10: resource allocation planning
Source: Internet
Author: User
Linux performance optimization 10: resource allocation planning 9: changing system default limits http://www.2cto.com/os/201307/228395.html We all know the two working modes of apache. in this section, we use the prefork mode to consider the configuration of apache applications! First, let's talk about performance tuning in linux. 10: resource allocation planning 9: changing default system limits http://www.2cto.com/os/201307/228395.html We all know the two working modes of apache. in this section, we use the prefork mode to consider the configuration of apache applications! 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. ######################################## ########################### StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 a server is definitely not here! MaxRequestsPerChild 4000 ######################################## ########################## Check the following data, I use AB for stress testing: AB-c 500-t 60 http://127.0.0.1/index.html Take a look at The memory occupied by an apache process: See the top man Document: 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)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.