You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dan Poirier <po...@pobox.com> on 2009/03/20 13:55:30 UTC

MaxClients reached message can be premature

httpd issues the message

"server reached MaxClients setting, consider raising the
MaxClients setting"

as soon as the number of spare threads drops below MinSpareThreads.  In
a pathological case where MinSpareThreads is high, the number of threads 
actually in use might be nowhere near MaxClients.

Here's a possible solution.  It checks whether we're really at
MaxClients,
or just below MinSpareThreads, and issues a more accurate message.  The
new
message will only be issued once.  If we do hit MaxClients for real, the 
original message will still be issued.

The patch is against trunk.

Dan

Index: server/mpm/worker/worker.c
===================================================================
--- server/mpm/worker/worker.c  (revision 756126)
+++ server/mpm/worker/worker.c  (working copy)
@@ -1509,15 +1509,27 @@
         /* terminate the free list */
         if (free_length == 0) { /* scoreboard is full, can't fork */
 
-            if (active_thread_count >= ap_daemons_limit *
ap_threads_per_child) { 
-                static int reported = 0;
-                if (!reported) {
-                    /* only report this condition once */
-                    ap_log_error(APLOG_MARK, APLOG_ERR, 0,
-                                 ap_server_conf,
-                                 "server reached MaxClients setting,
consider"
-                                 " raising the MaxClients setting");
-                    reported = 1;
+            if (active_thread_count >= ap_daemons_limit *
ap_threads_per_child) {
+                /* no threads are "inactive" - starting, stopping, etc.
*/
+                /* Are all threads in use? */
+                if (0 == idle_thread_count) {
+                    static int reported = 0;
+                    if (!reported) {
+                        /* only report this condition once */
+                        ap_log_error(APLOG_MARK, APLOG_ERR, 0,
+                                     ap_server_conf,
+                                     "server reached MaxClients
setting, consider"
+                                     " raising the MaxClients
setting");
+                        reported = 1;
+                    }
+                } else {
+                    static int reported = 0;
+                    if (!reported) {
+                        ap_log_error(APLOG_MARK, APLOG_ERR, 0,
+                                     ap_server_conf,
+                                     "server is within MinSpareThreads
of MaxClients, "
+                                     "consider raising the MaxClients
setting");
+                    }
                 }
             }
             else {



Re: MaxClients reached message can be premature

Posted by Dan Poirier <po...@pobox.com>.
"Dan Poirier" <po...@pobox.com> writes:

> httpd issues the message
>
> "server reached MaxClients setting, consider raising the
> MaxClients setting"
>
> as soon as the number of spare threads drops below MinSpareThreads.  In
> a pathological case where MinSpareThreads is high, the number of threads 
> actually in use might be nowhere near MaxClients.
>
> Here's a possible solution.  It checks whether we're really at
> MaxClients, or just below MinSpareThreads, and issues a more accurate
> message.  The new message will only be issued once.  If we do hit
> MaxClients for real, the original message will still be issued.

Thanks to Greg Ames who pointed out that I forgot to set the reported
flag after issuing the new message.

Any other comments?

-- 
Dan Poirier <po...@pobox.com>


Re: MaxClients reached message can be premature

Posted by Dan Poirier <po...@pobox.com>.
Sorry, my email client mangled that patch.  Trying another
one:

Index: server/mpm/worker/worker.c
===================================================================
--- server/mpm/worker/worker.c	(revision 756126)
+++ server/mpm/worker/worker.c	(working copy)
@@ -1509,15 +1509,27 @@
         /* terminate the free list */
         if (free_length == 0) { /* scoreboard is full, can't fork */
 
-            if (active_thread_count >= ap_daemons_limit * ap_threads_per_child) { 
-                static int reported = 0;
-                if (!reported) {
-                    /* only report this condition once */
-                    ap_log_error(APLOG_MARK, APLOG_ERR, 0,
-                                 ap_server_conf,
-                                 "server reached MaxClients setting, consider"
-                                 " raising the MaxClients setting");
-                    reported = 1;
+            if (active_thread_count >= ap_daemons_limit * ap_threads_per_child) {
+                /* no threads are "inactive" - starting, stopping, etc. */
+                /* Are all threads in use? */
+                if (0 == idle_thread_count) {
+                    static int reported = 0;
+                    if (!reported) {
+                        /* only report this condition once */
+                        ap_log_error(APLOG_MARK, APLOG_ERR, 0,
+                                     ap_server_conf,
+                                     "server reached MaxClients setting, consider"
+                                     " raising the MaxClients setting");
+                        reported = 1;
+                    }
+                } else {
+                    static int reported = 0;
+                    if (!reported) {
+                        ap_log_error(APLOG_MARK, APLOG_ERR, 0,
+                                     ap_server_conf,
+                                     "server is within MinSpareThreads of MaxClients, "
+                                     "consider raising the MaxClients setting");
+                    }
                 }
             }
             else {