Apache memory released ~

Source: Internet
Author: User
Q: Does an apache.exe occupy several hundred megabytes of memory during the continuous operation of the worker server after multiple days or after the peak value?
A: use NotePad to open apache2 \ conf \ httpd. conf, search for maxrequestsperchild, and change maxrequestsperchild 0 to maxrequestsperchild 50.

Generally, two apache.exe processes can be viewed in the "Windows Task Manager" process. One is the parent process and the other is the child process. After receiving the access request, the parent process submits the request to the child process for processing. The maxrequestsperchild command sets the number of requests that an independent sub-process can process. After the "maxrequestsperchild number" request is processed, the child process will be terminated by the parent process. At this time, the memory occupied by the child process will be released. If there are other access requests, the parent process re-generates the child process for processing.
If maxrequestsperchild is set to 0 (unlimited) by default or a large number (such as more than 10000), each sub-process can process more requests, it will not reduce the access efficiency because of continuous termination or promoter processes, but if maxrequestsperchild is set to 0, if it occupies 200 ~ MB of memory, even if the load is down, the occupied memory will not be reduced. A server with a large memory can be set to 0 or a large number. Servers with small memory can be set to 30, 50, or 100 to prevent memory overflow.

========================================================== ======================================
Apache memory usage

When the Apache process uses the memory, it is "getting longer. That is to say, until the process dies, the amount of memory used continues to grow and will not decrease. In this way, the memory usage of Apache processes depends on the maximum memory usage of your applications.

Keepalive Parameters

The keepalivetimeout parameter determines how long an HTTP Process can wait before nothing is done? Imagine that if keepalive is set to on and keepalivetimeout is set to a relatively large number, Apache will quickly increase its memory usage. This is because an Apache process completes a task (and reaches a certain amount of memory usage, think about the "gradual" mode) and does not immediately exit, but waits for a keepalivetimeout time. Assuming that the user's connection requests continue to come, a considerable number of useless Apache processes will be accumulated until timeout, and these processes will be killed.

However, keepalive is indeed more effective for static files than for transferring objects like files. Therefore, keepalive must be set to on, but keepalvietimeout must be set to a smaller value, for example, 5 s.

Maxrequestsperchild

This parameter indicates the number of requests processed by the Apache process, which must be exited and restarted to avoid memory problems.

For PHP scripts, it is advantageous to set a smaller parameter to avoid the pressure on Apache due to the continuous growth of memory used by the Program: Let this parameter regularly release the memory, because PHP Automatically releases only resources (memory) after the script is executed.

For example, set it to 50? If it is too small, it will consume resources to re-generate an Apache process, which is a balance problem.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.