Bug 64066 - httpd slow on startup/reload when many vhosts are configured
Summary: httpd slow on startup/reload when many vhosts are configured
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.4.41
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-09 15:01 UTC by Giovanni Bechis
Modified: 2020-02-07 17:20 UTC (History)
0 users



Attachments
Configuration load speed improvement (906 bytes, patch)
2020-01-09 15:01 UTC, Giovanni Bechis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bechis 2020-01-09 15:01:10 UTC
Created attachment 36959 [details]
Configuration load speed improvement

The httpd(8) startup and "graceful restart" time can be very long (~45s) with a large amount of vhosts (5k), defeating the purpose of "graceful restart" by causing client timeouts.
This appears to be the result of many calls to ap_find_command() which searches for a command by walking a simple array of command_rec structures and doing a string comparison between the name element of the structure and the desired command name. 

To reproduce the issue a configuration with at least 5k vhosts is needed;
with a similar config startup is slow and, after sending USR1 signal httpd(8)
becomes unresponsive for many seconds and this can cause client timeouts.

Httpd already has a hash of directives that is builds internally.
As this was most of the startup time we can avoid the manual array search.
For configurations with many directives this reduces the startup time by at least an order of magnitude.

Bug analysis and patch authored by cPanel.
Comment 1 Jim Jagielski 2020-01-14 17:12:39 UTC
Thank you for the patch. This looks very useful indeed. I will check and, if it passes all tests, apply to trunk w/ a back port to 2.4.x
Comment 2 Giovanni Bechis 2020-01-21 10:26:38 UTC
for the archives, committed in trunk in r1872786.
Comment 3 Giovanni Bechis 2020-02-07 17:19:46 UTC
Backported to 2.4 in commit r1872786.
Comment 4 Giovanni Bechis 2020-02-07 17:20:47 UTC
Backported in 2.4 in commit r1873738.