Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy - stop catering requests on 500 from server

Tags:

ubuntu

haproxy

Is there any way to stop catering further requests to server from HAProxy when a bankend server sends a 500?

When a server receives a signal like SIGINT, it will start serving "500 Server Internal Error" . SO when HAProxy detects 500 response from server, will it be able to stop further requests to the server?

There is a macro "on-error" which is enabled by default in server section. Trying that did not yield any result. For example:

server nucleus_server1 127.0.0.1:12341 check on-error mark-down

.the macro on-mark-down is not working along with this.

Any ideas?

like image 504
Neil Avatar asked Feb 27 '13 10:02

Neil


1 Answers

If you want HAProxy marks server as DOWN based on return code sends by this server add 'observe layer7' option to server definition. For your example, it could look like:

server nucleus_server1 127.0.0.1:12341 check on-error mark-down observe layer7 error-limit 1

It means that if nucleus_server1 returns 500 to any client request it will be removed from the pool. By 'error-limit' you can configure how many 500's have to be returned to mark this server as 'DOWN'.

Server will be marked as 'UP' again if internal HAProxy check success (by default 2 times).

Take a look on: check, fall, raise, error-limit, observe options in HAProxy documentation for more info.

like image 79
faja Avatar answered Oct 01 '22 01:10

faja