Apache [Error] server reached maxclients setting, consider raising the maxclients Setting Problem and Solution

Source: Internet
Author: User
Tags apache log

Recently, a customer reported an error message in the Apache log/var/log/httpd/error_log file after running for a period of time.

[Fri Mar 04 10:48:20 2011] [Error] server reached maxclients setting, consider raising the maxclients setting

After checking, this is caused by a large number of concurrent connections. Later, I checked the Apache document and found that the Apache configuration file can be modified.

Set the maxclients parameter in/etc/httpd/CONF/httpd. conf.

Before making adjustments, first check the prefork or worker modes in which Apache runs (for details about the differences between prefork and worker, refer to the following Google ), if you do not know which mode your Apache is, you can run the "/usr/sbin/httpd-L" command to check the mode, you can find/etc/httpd/CONF/httpd. conf to modify the configuration.

Here we will first reproduce the problem above and first write a PHP test.ProgramTest. php and put it in the/var/www/html/test. php location. The file content is relatively simple. simulate a simple page with the following content:

<? <Br/> sleep (1); <br/> phpinfo (); <br/>?> 

Then you can use the test tool AB provided by Apache to perform the test and run "AB-C 512-N 100000 http: // localhost/test. for testing, "-N 100000" refers to a total of 100,000 requests, and "-C 512" refers to the concurrency of 512 requests. After running, few successful requests can be found, and the above error will soon appear in the log. This is because the prefork mode is run in Apache in my environment. The maxclients parameter is 256 by default, therefore, this error occurs when the concurrency is high, which is 512.

Next, modify the parameters.

<Ifmodule prefork. c> <br/> startservers 8 <br/> minspareservers 5 <br/> maxspareservers 20 <br/> serverlimit 256 <br/> maxclients 256 <br/> maxrequestsperchild 4000 <br /> </ifmodule> 

Change

<Ifmodule prefork. c> <br/> startservers 100 <br/> minspareservers 100 <br/> maxspareservers 100 <br/> serverlimit 1024 <br/> maxclients 1024 <br/> maxrequestsperchild 4000 <br /> </ifmodule> 

Note that I have configured maxclients = 1024, and I only used 512 concurrent requests in the test, leaving some room for further adjustments in the specific environment.

Then restart Apache "/etc/init. d/httpd restart ".

Run "AB-C 512-N 100000 http: // localhost/test. php" again, you can find that all requests are successfully completed, and there is no longer the above error in the log.

 

 

The parameter meanings are described in Apache configuration as follows:

# Prefork MPM <br/> # startservers: Number of server processes to start <br/> # minspareservers: Minimum number of server processes which are kept spare <br/> # maxspareservers: maximum number of server processes which are kept spare <br/> # serverlimit: maximum value for maxclients for the lifetime of the server <br/> # maxclients: maximum number of server processes allowed to start <br/> # maxrequestsperchild: Maximum number of requests a server process serves 

 

# Worker MPM <br/> # startservers: initial number of server processes to start <br/> # maxclients: Maximum number of simultaneous client connections <br/> # minsparethreads: minimum number of worker threads which are kept spare <br/> # maxsparethreads: Maximum number of worker threads which are kept spare <br/> # threadsperchild: constant Number of worker threads in each server process <br/> # maxrequestsperchild: Maximum number of requests a server process serves <br/> 

 

 

 

 

 

 

 

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.