Hi,

On Fri, Nov 04, 2016 at 07:27:46PM +0100, [email protected] wrote:
> Hi,
> 
> i would like to implement a circuit breaker functionality with the help of
> HAProxy.
> 
> For example, if the average response time of the http requests of a backend
> server is above a certain threshold in the last x seconds, trip the circuit
> breaker for a period of x seconds (respond with 503 and/or show error page
> etc.). After the period has expired, close the circuit and forward requests
> to the server as normal.
> The same logic should be applied to http response status (if a defined
> status (500) is above a ratio of 1% of all requests).
> 
> I want to use HAProxy for this task to not need to implement this
> functionality/pattern in every single application or (micro)service.
> 
> I'm aware of "observe layer7" or "http_err_rate" fetch, but these doesn't
> fulfill the requirements.
> 
> At the moment i haven't found a way to implement this with HAProxy built-in
> functions.
> 
> I can think of a Lua solution, but i'm not sure if this is possible. I need
> to save the backend response time of every transaction in a shared memory
> segment (i want to avoid Redis if possible). Then read from this segment,
> implement a sliding window and decide based on calculations+thresholds if
> the circuit breaker should be tripped. A similar logic applies to http
> response status.
> 
> 
> Any ideas on this?

Just ouy of my head right now, given that you can store these info over a
period in a stick table, you could decide to maintain an entry indexed on
a constant value so that any request would use the same entry. For example
let's say you track the constant "0" for each request, and your stick-table
stores http_err_rate and http_req_rate, you could have these two values
and try to perform some operations on them. Hmmm we still don't have the
arithmetic operators on variables so you'll have to resort to Lua for this.

These are just a few hints in case that helps you move forward.

Cheers,
Willy

Reply via email to