In order to make a true per-IP limit for Thumbor with no locking secondary effects, we would need an additional piece of functionality that haproxy doesn't provide.
The desired properties are:
- the ability to limit the amount of Thumbor workers/connections dedicated to a particular client, based on the X-Forwarded-For header
- the ability to have a FIFO request queue per client for requests beyond the concurrency limit
- a queue size limit to error immediately when a client sends too many requests (with possibly a concurrency penalty too)
Most reverse proxies only support erroring when a client goes over a certain limit, not queueing requests for that client. While haproxy has a request queue for its general pool of incoming requests, it cannot be controlled. Lua scripting in haproxy allows to error but not queue requests based on the criteria defined above.
As simple as the requirements above sound, I have so far been unable to find an existing FLOSS service that can support this feature set.