haproxy public development tree
Go to file
Krzysztof Piotr Oledzki 5a329cf017 [MEDIUM]: Prevent redispatcher from selecting the same server, version #3
When haproxy decides that session needs to be redispatched it chose a server,
but there is no guarantee for it to be a different one. So, it often
happens that selected server is exactly the same that it was previously, so
a client ends up with a 503 error anyway, especially when one sever has
much bigger weight than others.

Changes from the previous version:
 - drop stupid and unnecessary SN_DIRECT changes

 - assign_server(): use srvtoavoid to keep the old server and clear s->srv
    so SRV_STATUS_NOSRV guarantees that t->srv == NULL (again)
    and get_server_rr_with_conns has chances to work (previously
    we were passing a NULL here)

 - srv_redispatch_connect(): remove t->srv->cum_sess and t->srv->failed_conns
   incrementing as t->srv was guaranteed to be NULL

 - add avoididx to get_server_rr_with_conns. I hope I correctly understand this code.

 - fix http_flush_cookie_flags() and move it to assign_server_and_queue()
   directly. The code here was supposed to set CK_DOWN and clear CK_VALID,
   but: (TX_CK_VALID | TX_CK_DOWN) == TX_CK_VALID == TX_CK_MASK so:
	if ((txn->flags & TX_CK_MASK) == TX_CK_VALID)
		txn->flags ^= (TX_CK_VALID | TX_CK_DOWN);
   was really a:
	if ((txn->flags & TX_CK_MASK) == TX_CK_VALID)
		txn->flags &= TX_CK_VALID

   Now haproxy logs "--DI" after redispatching connection.

 - defer srv->redispatches++ and s->be->redispatches++ so there
   are called only if a conenction was redispatched, not only
   supposed to.

 - don't increment lbconn if redispatcher selected the same sarver

 - don't count unsuccessfully redispatched connections as redispatched
   connections

 - don't count redispatched connections as errors, so:

 - the number of connections effectively served by a server is:
 srv->cum_sess - srv->failed_conns - srv->retries - srv->redispatches
   and
 SUM(servers->failed_conns) == be->failed_conns

 - requires the "Don't increment server connections too much + fix retries" patch

 - needs little more testing and probably some discussion so reverting to the RFC state

Tests #1:
 retries 4
 redispatch

i) 1 server(s): b (wght=1, down)
  b) sessions=5, lbtot=1, err_conn=1, retr=4, redis=0
  -> request failed

ii) server(s): b (wght=1, down), u (wght=1, down)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=1, retr=0, redis=0
  -> request FAILED

iii) 2 server(s): b (wght=1, down), u (wght=1, up)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=0, retr=0, redis=0
  -> request OK

iv) 2 server(s): b (wght=100, down), u (wght=1, up)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=0, retr=0, redis=0
  -> request OK

v) 1 server(s): b (down for first 4 SYNS)
  b) sessions=5, lbtot=1, err_conn=0, retr=4, redis=0
  -> request OK

Tests #2:
 retries 4

i) 1 server(s): b (down)
  b) sessions=5, lbtot=1, err_conn=1, retr=4, redis=0
  -> request FAILED
2008-03-04 06:16:37 +01:00
doc [MINOR] Implement persistent id for proxies and servers 2008-02-28 17:23:59 +01:00
examples [MINOR] report correct section type for unknown keywords. 2008-01-22 16:44:08 +01:00
include [MEDIUM]: Prevent redispatcher from selecting the same server, version #3 2008-03-04 06:16:37 +01:00
src [MEDIUM]: Prevent redispatcher from selecting the same server, version #3 2008-03-04 06:16:37 +01:00
tests [TESTS] add test-pollers.cfg to easily report pollers in use 2008-02-16 20:02:48 +01:00
.gitignore [BUILD] updated .gitignore 2006-12-19 18:03:12 +01:00
CHANGELOG [RELEASE] Released version 1.3.14 2007-12-06 01:25:44 +01:00
CONTRIB [DOC] Update a "contrib" file with a hint about a scheme used for formathing subjects 2008-02-04 21:34:59 +01:00
LICENSE [LICENSE] licensing clarifications 2006-06-15 21:48:13 +02:00
Makefile [BUILD] ensure that makefile understands USE_DLMALLOC=1 2008-02-19 10:53:32 +01:00
Makefile.bsd [MINOR] store the build options to report with -vv 2007-12-02 11:28:59 +01:00
Makefile.osx [BUILD] update MacOS Makefile to build on newer versions 2008-02-10 17:00:13 +01:00
README Separated OpenBSD build from the main Makefile into a new one. 2006-03-19 20:56:52 +01:00
ROADMAP [MEDIUM] implemented the 'monitor-uri' keyword. 2006-07-09 17:01:40 +02:00
SUBVERS [BUILD] centralize version and date into one file for each 2007-09-09 23:31:11 +02:00
TODO [MEDIUM] Implement "track [<backend>/]<server>" 2008-02-27 10:39:53 +01:00
VERDATE [RELEASE] Released version 1.3.14 2007-12-06 01:25:44 +01:00
VERSION [RELEASE] Released version 1.3.14 2007-12-06 01:25:44 +01:00

README

                           -------------------
                             H A - P r o x y
                             How to build it
                           -------------------
                              version 1.2.7
                              willy tarreau
                                2005/10/25


To build haproxy, you will need :
  - GNU make. Neither Solaris nor OpenBSD's make work with this makefile.
  - GCC between 2.91 and 3.4. Others may work, but not tested.
  - GNU ld

Also, you might want to build with libpcre support, which will provide a very
efficient regex implementation and will also fix some badness on Solaris's one.

To build haproxy, you have to choose your target OS amongst the following ones
and assign it to the TARGET variable :

  - linux24  for Linux 2.4 and above (default)
  - linux24e for Linux 2.4 with support for epoll
  - linux26  for Linux 2.6 and above
  - linux22  for Linux 2.2
  - solaris  for Solaris 8 or 10 (others untested)
  - openbsd  for OpenBSD 3.1 to 3.7 (others untested)
  - generic  for any other OS.

You may also choose your CPU to benefit from some optimizations. This is
particularly important on UltraSparc machines. For this, you can assign
one of the following choices to the CPU variable :

  - i686 for intel PentiumPro, Pentium 2 and above, AMD Athlon
  - i586 for intel Pentium, AMD K6, VIA C3.
  - ultrasparc : Sun UltraSparc I/II/III/IV processor
  - generic : any other processor or no specific optimization. (default)

If your system supports PCRE (Perl Compatible Regular Expressions), then you
really should build with libpcre which is between 2 and 10 times faster than
other libc implementations. Regex are used for header processing (deletion,
rewriting, allow, deny). The only inconvenient of libpcre is that it is not
yet widely spread, so if you build for other systems, you might get into
trouble if they don't have the dynamic library. In this situation, you should
statically link libpcre into haproxy so that it will not be necessary to
install it on target systems. Available options for the REGEX variable are :

  - libc to use your OS libc's standard regex implemntation (default).
    Warning! group references on Solaris seem broken. Use static-pcre whenever
    possible.

  - pcre to use libpcre, in whatever form it is available on your system
    (shared or static)

  - static-pcre to use a static version of libpcre even if the dynamic one is
    available. This will enhance portability.

By default, the DEBUG variable is set to '-g' to enable debug symbols. It is
not wise to disable it on uncommon systems, because it's often the only way to
get a complete core when you need one. Otherwise, you can set DEBUG to '-s' to
strip the binary.

For example, I use this to build for Solaris 8 :

    $ make TARGET=solaris CPU=ultrasparc REGEX=static-pcre

And I build it this way on OpenBSD :

    $ make -f Makefile.bsd REGEX=pcre DEBUG= COPTS.generic="-Os -fomit-frame-pointer -mgnu"

If you need to pass other defines, includes, libraries, etc... then please
check the Makefile to see which ones will be available in your case, and
use the ADDINC, ADDLIB, and DEFINE variables for this.

-- end