mod_h2: Idle H2 threads don't terminate on "graceful" Apache restart (mpm_event)

Vanilla Apache with “mpm_event” functions in the following way after a “graceful” restart:

  1. Old child processes which serve no requests are terminated immediately.
  2. Old child processes which have threads busy with existing requests are left alive. The busy threads continue to work until the requests are completed. The idle threads are terminated immediately.

This is an efficient way to handle “graceful” restarts because we can increase the ServerLimit a lot, in order to accommodate lots of old child processes (finishing a few old connections), and have a couple of up-to-date active child processes (with lots of threads waiting to serve new clients).

The old child processes allocate very few memory resources because most of their threads are terminated.

Unfortunately, mod_http2 doesn’t honor the “graceful” restart. None of the following settings made any difference during my tests:

  1. H2MinWorkers 1 (additionally, I figured out that this isn’t honored at all because a lot of H2 threads are always created, even for an idle Apache server which just started)
  2. H2MaxWorkerIdleSeconds 5 (the idle H2 thread live forever regardless of this setting combined with H2MinWorkers 1)

The old Apache child processes keep all their H2 threads active forever, regardless of the fact that most of those H2 threads are idle. I will appreciate it if you can look into this.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 64 (34 by maintainers)

Commits related to this issue

Most upvoted comments

No, and the bug becomes visible when you tell the server to stop. Then something like this would be in your logs:

I think OP may see similar result, with less logging, from MaxRequestsPerChild/MaxConnectionsPerChild nonzero or MaxSpareThreads < MaxClients too.