You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Michal Kováčik <ko...@gmail.com> on 2020/03/20 16:20:41 UTC

[users@httpd] Asynchronous HTTP proxy

Hi,

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/5
ProxyPassReverse /test http://httpbin.org/delay/5


We 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.

Thank you!

Re: [users@httpd] Asynchronous HTTP proxy

Posted by Eric Covener <co...@gmail.com>.
On Tue, Mar 24, 2020 at 10:07 AM Michal Kováčik <ko...@gmail.com> wrote:
>
> Well is there any chance you plan to support some kind of multiplexing?
>
> Our use case is that we have Apache configured to use thousands of connections to interactive servers, but we also have websockets running through same set of Apache servers. As these connections are blocking we could eventually hit the maximum and completely "clog" the server. Increasing setting to more workers doesn't scale.
> We are currently using worker MPM and we hoped that event MPM can resolve this. Did we misunderstood how event MPM should work?

In trunk / 2.5.0 mod_proxy_wstunnel has some async support so idle
websocket connections don't tie up a thread.  This only helps if your
websockets traffic is proxied.

Event only offloads some very specific things, it doesn't cause this
kind of multiplexing for most of request processing (for example while
a slow CGI is running or while mod_proxy_http is waiting for the first
byte or a subsequent byte)

Event does help a lot with keepalive and write completion (slow
reading clients) and connection shutdown tieing up threads.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Asynchronous HTTP proxy

Posted by Michal Kováčik <ko...@gmail.com>.
Well is there any chance you plan to support some kind of multiplexing?

Our use case is that we have Apache configured to use thousands of
connections to interactive servers, but we also have websockets running
through same set of Apache servers. As these connections are blocking we
could eventually hit the maximum and completely "clog" the server.
Increasing setting to more workers doesn't scale.
We are currently using worker MPM and we hoped that event MPM can resolve
this. Did we misunderstood how event MPM should work?

On Fri, Mar 20, 2020 at 5:40 PM Eric Covener <co...@gmail.com> wrote:

> > 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.
>
> no, that's not the way it works.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Asynchronous HTTP proxy

Posted by Eric Covener <co...@gmail.com>.
> 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.

no, that's not the way it works.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org