Can we handle multiple HTTP/1.1 requests concurrently within a single-processed single-threaded Apache HTTPD 2.4.41? Does Apache HTTPD 2.4.41 support TCP multiplexing via Linux epoll or BSD kqueue call? We tried a few different apache configurations with event MPM or worker MPM, but we could not achieve desired results.
Our Apache-2.4.41 was built with the following parameters:
Server version: Apache/2.4.41 (Unix)
Server built: Feb 27 2020 14:04:59
Server's Module Magic Number: 20120211:88
Server loaded: APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr/local/httpd-2.4.41"
-D SUEXEC_BIN="/usr/local/httpd-2.4.41/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
Our httpd.conf restricted the apache proxy server to run in the single-processed / single-threaded mode, forwarding requests to
http://httpbin.org/delay/5 (to respond with a 5-second delay).
ServerLimit 1
StartServers 1
MinSpareThreads 1
MaxSpareThreads 1
ThreadsPerChild 1
MaxConnectionsPerChild 0
ProxyPass /test
http://httpbin.org/delay/5ProxyPassReverse /test
http://httpbin.org/delay/5We used the curl client to submit 5 concurrent requests:
#!/bin/sh
i=0
while [ $i -lt 5 ]; do
curl -sw "TIME: %{time_total} sec\n--------------------------------------------------\n"
http://localhost/WING &
i=$(expr $i + 1)
done
wait
We expected to receive all 5 resonses in 5 seconds (we could do this with nginx or h2o servers). However, that did not happen, apache serialized the requests and the whole test took 45 seconds.
1st RESPONSE: 5.250462 sec
2nd RESPONSE: 15.371989 sec
3rd RESPONSE: 25.491191 sec
4th RESPONSE: 35.612617 sec
5th RESPONSE: 45.725523 sec
We could collect all responses in 5 seconds, however, we had to configure apache to launch 5 or more threads. To compare, with nginx-1.16.1 we got the following results in the single-processed and single-threaded mode.
1st RESPONSE: 5.289 sec
2nd RESPONSE: 5.295 sec
3rd RESPONSE: 5.307 sec
4th RESPONSE: 5.308 sec
5th RESPONSE: 5.312 sec
Please advise if it is possible to build and configure Apache-2.4.41 to multiplex connections and to process multiple concurrent HTTP/1.1 requests from a single-thread.