Skip navigation.

Is it a good idea to put Apache httpd in front of a Bayeux server ?

Is it a good idea to put Apache httpd in front of a Bayeux server ?

The problem of putting Apache httpd in front of a Bayeux server is that it will not scale well for moderate to heavy loads.

The reason is that Apache httpd uses the thread-per-request model, which does not scale well in case of long polling connections.
Imagine 1000 Bayeux clients connected to Apache httpd; in such case, Apache httpd will have 1000 outstanding requests for the long polls only, plus any request that may be performed by the clients, so in total 1000+ threads concurrently active at any given time.
The burden of this model on memory and scheduling is quite high.

The asynchronous I/O features of a Bayeux server like Jetty allow to handle the same 1000 Bayeux clients with less than 10 concurrently active threads.
Assume 1000 Bayeux clients long polling every 20 seconds, and assume that each long poll request takes 100 ms to be processed, then we have

1000 long poll requests / 20 s = 50 requests/s
50 requests/s * 100 ms/request = 5 concurrent requests at any given time
5 concurrent requests at any given time => 5 threads active at any given time

Therefore 5 threads are needed by Jetty to handle 1000 Bayeux clients long polling where Apache httpd would need 1000 threads (and we assumed a large processing time of 100 ms/request whereas usual figures are way less than that).

If you have deployments where you expect 500+/1000+ Bayeux clients connected, then Jetty will scale a lot better than Apache httpd.

The problem is not Apache httpd, which is a great server; it is its thread-per-request model.
Therefore, any server using that model will suffer the same problems.
Here we mentioned Apache httpd because it is the most used solution used as front-end for web sites (and because it is a very frequently asked question).