I'm using HAProxy 1.8 to proxy requests to my HTTP API and now want to load-balance between multiple servers, so something like this:
backend http-in-backend
balance roundrobin
server api-server1 10.1.1.1:1234
server api-server1 10.1.1.2:1234
However, there are some requests that need to be sent to all servers. It's OK to return the response from any of them to the client in this case, as the response should be the same. Is there a way to do this? I can conditionally send those requests to a separate backend, of course. So the problem is really: how do I send one request to multiple servers and return the response from any one of them?
Apparently no way with haproxy: https://www.mail-archive.com/[email protected]/msg02138.html
Since the answers are outdated, I'd like to post a newer answer.
this is possible with SPOE engine "mirror" and is called traffic mirroring.
https://www.haproxy.com/de/blog/haproxy-traffic-mirroring-for-real-world-testing/
I currently need this too and I'm planning to implement this in the next weeks for the first time. If I have some useful experience, I'll come back here and add it.
This sounds more like the task for a message queue than for a reverse proxy. Look into RabbitMQ or similar to see how such a solution could be architected. One likely solution might be to have “any” server receive the request and then have it pass the relevant contents on to a queue to which “all” servers subscribe.