Having Apache (2.4.29) configured as reverse proxy for WebSocket requests with mod-proxy-wstunnel
:
ProxyPass "/myapp/ws" "ws://localhost:8080/myapp/ws"
For each active WebSocket client, I see an Apache worker that remains active (in "Sending Reply" status) as long as this client is kept alive even if there is no data being sent. In practice it means I cannot scale WebSocket clients because all available connections are consumed.
In /server-status there is one line like this for each client:
Srv PID Acc M CPU SS Req Conn Child Slot Client Protocol VHost Request
0-0 10219 0/43/43 _ 1.04 1828 984237 0.0 0.09 0.09 ::1 http/1.1 butler.openbravo.com:443 GET /myapp/ws/helloWs HTTP/1.1
Using different mpm
configurations (tested with event, worker and prefork) has no effect on this.
I would need Apache to be able to reuse these workers when they are sitting idle (no transferring any data) in order to be able to scale it. Is it possible?
No, it's not currently possible to multiplex websockets connections this way.
In httpd trunk (2.5.x) there are experimental options to allow these connections to go asynchronous after idle for some time. But it is unlikely to be something that would be backported to 2.4.x and there is not really a stable 2.6.x on the horizon at the moment.