You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2018/11/12 08:33:24 UTC

[Bug 62903] New: Better handling of a thread limit forced by cgroups via systemd

https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

            Bug ID: 62903
           Summary: Better handling of a thread limit forced by cgroups
                    via systemd
           Product: Apache httpd-2
           Version: 2.4.29
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: bugs@httpd.apache.org
          Reporter: ewasser@maxcluster.de
  Target Milestone: ---

Hi everyone,

this is mainly a copy of my posting on the httpd-users mailing list[1] because
I think there is a bug somewhere deep down:

I'm stumbled upon some strange issues with the apache2. At first some facts
about the environment there the apache2 was running:

* Virtuozzo 7 with a stripped down version of Ubuntu 18.04 as container OS.
* The thread/processes limit is set to 1500 for the container.
* The apache2 is using the `mpm_worker_module` with this configuration:

<IfModule mpm_worker_module>
     ServerLimit              16
     StartServers             3
     MinSpareThreads          75
     MaxSpareThreads          250
     ThreadLimit              64
     ThreadsPerChild          25
     MaxRequestWorkers        400
     MaxConnectionsPerChild   10000
</IfModule>

* I'm using apache2-2.4.29-1ubuntu4.4.

* I was dealing with some kind of benchmarking and I used this command `ab -kc
1000 -t 60 http://foo.invalid/` for it. The returned page was a simple static
HTML page with not FastCGI/PHP or any other "fancy" stuff.

I was expecting some delay with the benchmarks because the number of
connections `1000` were larger than the upper thread limit of the
`mpm_worker_module`. This should not a problem at all because apache2 shows
some good error messages if it runs into some process/thread limit.

But in this case, this is what I found in the `error.log` (removed the
timestamp for readability):

… [mpm_worker:alert] [pid 2835:tid 140106655919040] (11)Resource temporarily
unavailable: AH00282: apr_thread_create: unable to create worker thread
… [mpm_worker:alert] [pid 2898:tid 140106655919040] (11)Resource temporarily
unavailable: AH00282: apr_thread_create: unable to create worker thread
… [mpm_worker:alert] [pid 2938:tid 140106655919040] (11)Resource temporarily
unavailable: AH00282: apr_thread_create: unable to create worker thread

Or

… [mpm_worker:crit] [pid 25242:tid 140005187725056] (22)Invalid argument:
AH03139: ap_queue_pop failed
… [mpm_worker:crit] [pid 25242:tid 140005187725056] (22)Invalid argument:
AH03139: ap_queue_pop failed
… [mpm_worker:crit] [pid 25242:tid 140005187725056] (22)Invalid argument:
AH03139: ap_queue_pop failed
… [mpm_worker:alert] [pid 25396:tid 140005187929856] (11)Resource temporarily
unavailable: AH03142: apr_thread_create: unable to create worker thread

Or

… [core:error] [pid 401:tid 140005310155712] AH00546: no record of generation 0
of exiting child 25241
… [core:error] [pid 401:tid 140005310155712] AH00546: no record of generation 0
of exiting child 25396

And no other messages.

Sometimes the apache2 hangs with 100% CPU usage even after the ab testing was
long over. Here the line from `htop`:

 > 5875 www-data  20  0  372M  3340  1068 S 198.  0.1  0:31.16
/usr/sbin/apache2 -k start

The load was going up to 20 even without any further requests. I've to restart
the apache2 to fix this.

`strace` during the ab run shows this:

2835  clone(child_stack=0x7f6d09becf70, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,parent_tidptr=0x7f6d09bed9d0,
tls=0x7f6d09bed700, child_tidptr=0x7f6d09bed9d0) = -1 EAGAIN (Resource
temporarily unavailable)
2835  clone(child_stack=0x7f6d09becf70,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,parent_tidptr=0x7f6d09bed9d0,
tls=0x7f6d09bed700, child_tidptr=0x7f6d09bed9d0) = -1 EAGAIN (Resource
temporarily unavailable)
2835  clone(child_stack=0x7f6d09becf70,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,parent_tidptr=0x7f6d09bed9d0,
tls=0x7f6d09bed700, child_tidptr=0x7f6d09bed9d0) = -1 EAGAIN (Resource
temporarily unavailable)

So someone was holding back the apache2 from creating new threads. To make a
long story short: It was systemd that limited the total processes of the
apache2 cgroup to 225 threads:

$ systemctl status apache2 | grep Tasks
     Tasks: 194 (limit: 225)

Setting the systemd value `DefaultTasksMax=infinity` and everything was fine
but 2 questions are still remaining:

1. The error message shows that apache2 is not ready to handle successfully a
fail of the clone() call. I think this is a bug.

2. Can apache2 detect a task limit via cgroups on it's own to detect this kind
of misconfiguration? In this case the max configured threads were larger than
the limit of the cgroup. Is it possible to detect this and issue a warning to
the logfiles? In other cases of limits like these the apache2 is more helpful
with the given error messages.

[1]http://mail-archives.apache.org/mod_mbox/httpd-users/201810.mbox/%3C544ce613-3f9b-5f0f-c52e-2946af4396e9%40maxcluster.de%3E

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 62903] Better handling of a thread limit forced by cgroups via systemd

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

Rich Bowen <rb...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Rich Bowen <rb...@apache.org> ---
Thank you for your report. As part of an effort to clean up our issue tracker,
we are closing tickets that have seen no activity for more than 5 years. If
this issue is still relevant to a current version of Apache httpd (2.4.x or
trunk), please reopen this ticket or open a new one with updated information.
We appreciate your contribution to the project.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 62903] Better handling of a thread limit forced by cgroups via systemd

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

Erik Wasser <ew...@maxcluster.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 62903] Better handling of a thread limit forced by cgroups via systemd

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

--- Comment #2 from Erik Wasser <ew...@maxcluster.de> ---
The bug(?) is still there.

Some things have changes:

* Apache Version = 2.4.58-1ubuntu8.11
* OS = Ubuntu 24.04
* Container = LXD

Add this to the apache2.service

[Service]
TasksMax=225

And start the benchmark with `ab -kc 1000 -t 60 http://IP.IP.IP.IP/ 2>&1 | ts`

May 12 08:08:48 This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
May 12 08:08:48 Copyright 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/
May 12 08:08:48 Licensed to The Apache Software Foundation,
http://www.apache.org/
May 12 08:08:48 
May 12 08:08:48 Benchmarking IP.IP.IP.IP (be patient)
May 12 08:08:49 Completed 5000 requests
May 12 08:08:50 Completed 10000 requests
May 12 08:08:51 Completed 15000 requests
May 12 08:08:53 Completed 20000 requests
May 12 08:08:54 Completed 25000 requests
May 12 08:08:55 Completed 30000 requests
May 12 08:08:56 Completed 35000 requests
May 12 08:08:58 Completed 40000 requests
May 12 08:08:59 Completed 45000 requests

Please notice the pause here between these lines.

May 12 08:10:00 Finished 49705 requests
May 12 08:10:00 
May 12 08:10:00 
May 12 08:10:00 Server Software:        Apache
May 12 08:10:00 Server Hostname:        IP.IP.IP.IP
May 12 08:10:00 Server Port:            80
May 12 08:10:00 
May 12 08:10:00 Document Path:          /
May 12 08:10:00 Document Length:        24924 bytes
May 12 08:10:00 
May 12 08:10:00 Concurrency Level:      1000
May 12 08:10:00 Time taken for tests:   71.913 seconds
May 12 08:10:00 Complete requests:      49705
May 12 08:10:00 Failed requests:        301
May 12 08:10:00    (Connect: 0, Receive: 0, Length: 301, Exceptions: 0)
May 12 08:10:00 Keep-Alive requests:    49365
May 12 08:10:00 Total transferred:      1244587370 bytes
May 12 08:10:00 HTML transferred:       1231345296 bytes
May 12 08:10:00 Requests per second:    691.18 [#/sec] (mean)
May 12 08:10:00 Time per request:       1446.801 [ms] (mean)
May 12 08:10:00 Time per request:       1.447 [ms] (mean, across all concurrent
requests)
May 12 08:10:00 Transfer rate:          16901.16 [Kbytes/sec] received
May 12 08:10:00 
May 12 08:10:00 Connection Times (ms)
May 12 08:10:00               min  mean[+/-sd] median   max
May 12 08:10:00 Connect:        0    1   8.9      0     112
May 12 08:10:00 Processing:     6  376 3580.3     20   57023
May 12 08:10:00 Waiting:        5  414 4058.3     13   57018
May 12 08:10:00 Total:          6  377 3588.0     20   57130
May 12 08:10:00 
May 12 08:10:00 Percentage of the requests served within a certain time (ms)
May 12 08:10:00   50%     20
May 12 08:10:00   66%     24
May 12 08:10:00   75%     28
May 12 08:10:00   80%     29
May 12 08:10:00   90%     36
May 12 08:10:00   95%     56
May 12 08:10:00   98%    151
May 12 08:10:00   99%  15009
May 12 08:10:00  100%  57130 (longest request)

Other things haven't changed:

The error.log contains still this error message:

[Tue May 12 08:10:06.415072 2026] [mpm_worker:error] [pid 3035275:tid
125231809791872] (11)Resource temporarily unavailable: AH00283: fork: Unable to
fork new process

So my 2 questions from the original are still valid. And I add 2 more
questions:

3. Why the pause in the output of the benchmark?
4. Why are there errors showning up in the benchmark?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 62903] Better handling of a thread limit forced by cgroups via systemd

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

Erik Wasser <ew...@maxcluster.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ewasser@maxcluster.de

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 62903] Better handling of a thread limit forced by cgroups via systemd

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62903

Joe Orton <jo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|REOPENED                    |RESOLVED

--- Comment #3 from Joe Orton <jo...@apache.org> ---
These errors are symptomatic of failing to tune the server to the environment,
all the Unix MPMs have a sleep(10) in the case of fork() failing in the parent,
possibly what you're seeing there with the benchmarking "stalling". And hitting
clone() failures is the same problem.

Answer is the same: tune the server to the environment.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org