Commit Graph

670 Commits

Author SHA1 Message Date
Willy Tarreau
98edd77891 [MINOR] fix the status return of the init script
R.I. Pienaar reported to me that the init script provided with
haproxy did not correctly report the status of the rhstatus()
function. In fact this was caused by the "exit $RETVAL" instead
of "exit $?" at the end.
2007-12-02 14:02:52 +01:00
Willy Tarreau
7b066db3bf [MINOR] store the build options to report with -vv
Sometimes it is useful to find out how a given binary version was
built. The build compiler and options are now provided for this,
and it's possible to get them with the -vv option.
2007-12-02 11:28:59 +01:00
Willy Tarreau
b698f0f4a2 [CLEANUP] fwrr: ensure that we never overflow in placements
Now we can compute the max place depending on the number of servers,
maximum weight and weight scale. The formula has been stored as a
comment so that it's easy to choose between smooth weight ramp up
and high number of servers. The default scale has been set to 16,
which permits 4000 servers with a granularity of 6% in the worst
case (weight=1).
2007-12-02 11:01:23 +01:00
Willy Tarreau
d1cd276456 [CLEANUP] remove a warning from gcc due to htons() in standard.c
Due to the fact that htons is defined as a macro, it's dangerous
to call it with auto-incremented arguments such as htons(f(++x)) :

src/standard.c: In function 'url2sa':
src/standard.c:291: warning: operation on 'curr' may be undefined

The solution is simply to store the intermediate result an pass it
to htons() at once.
2007-12-02 10:55:56 +01:00
Willy Tarreau
b80c230f41 [MEDIUM] add the "fail" condition to monitor requests
Under certain circumstances, it is very useful to be able to fail some
monitor requests. One specific case is when the number of servers in
the backend falls below a certain level. The new "monitor fail" construct
followed by either "if"/"unless" <condition> makes it possible to specify
ACL-based conditions which will make the monitor return 503 instead of
200. Any number of conditions can be passed. Another use may be to limit
the requests to local networks only.
2007-11-30 20:51:32 +01:00
Willy Tarreau
a9d3c1e6a3 [MEDIUM] add the "nbsrv" ACL verb
The new "nbsrv" ACL verb matches the number of active servers in a backend.
By default, it applies to the backend where it is declared, but optionally
it can receive the name of another backend as an argument in parenthesis.

It counts the number of enabled active servers first, then the number of
enabled backup servers.
2007-11-30 20:48:53 +01:00
Willy Tarreau
c8f24f8ec1 [BUILD] fix 2 minor issues on AIX
AIX does not know about MSG_DONTWAIT. Fortunately, nearly all sockets
are already set to O_NONBLOCK, so it's not even required to change the
code.  It was only necessary to add this fcntl to the log socket which
lacked it.  The MSG_DONTWAIT value has been defined to zero when unset
in order to make the code cleaner and more portable.

Also, on AIX, "hz" is defined, which causes a problem with one function
parameter in time.c. It's enough to rename the parameter there. Last,
fix a missing #include <string.h> in proxy.c.
2007-11-30 18:38:35 +01:00
Willy Tarreau
4bab24d955 [MINOR] stats: report the server warm up status in a "throttle" column
A new "throttle" column has been added to HTML and RAW stats to indicate
in percent, the level of throttling due to server warmup. The column is
empty at 100%.
2007-11-30 18:16:29 +01:00
Willy Tarreau
5764b38c38 [DOC] document the server's slowstart parameter 2007-11-30 17:46:49 +01:00
Willy Tarreau
9909fc13f1 [MEDIUM] implement the slowstart parameter for servers
The new 'slowstart' parameter for a server accepts a value in
milliseconds which indicates after how long a server which has
just come back up will run at full speed. The speed grows
linearly from 0 to 100% during this time. The limitation applies
to two parameters :

  - maxconn: the number of connections accepted by the server
    will grow from 1 to 100% of the usual dynamic limit defined
    by (minconn,maxconn,fullconn).

  - weight: when the backend uses a dynamic weighted algorithm,
    the weight grows linearly from 1 to 100%. In this case, the
    weight is updated at every health-check. For this reason, it
    is important that the 'inter' parameter is smaller than the
    'slowstart', in order to maximize the number of steps.

The slowstart never applies when haproxy starts, otherwise it
would cause trouble to running servers. It only applies when
a server has been previously seen as failed.
2007-11-30 17:42:05 +01:00
Willy Tarreau
df36614b97 [CLEANUP] use distinct bits per load-balancing algorithm type
It's useful to be able to check against an LB algorithm type by
testing just one bit.
2007-11-30 16:23:20 +01:00
Willy Tarreau
4689ae6e79 [TESTS] add a test file for disable-on-404 2007-11-30 15:23:38 +01:00
Willy Tarreau
8293658170 [MINOR] http-check disable-on-404 is not limited to HTTP mode
This option is for health-checks, do not limit it to HTTP proxies.
2007-11-30 15:20:09 +01:00
Willy Tarreau
dbc36f6e44 [DOC] document the "http-check disable-on-404" option 2007-11-30 12:29:11 +01:00
Willy Tarreau
2ea81930e7 [MEDIUM] report disabled servers as "NOLB" when they are still UP
It's important to be able to distinguish between servers which are UP
and those which are UP but disabled via a 404 response. For this reason,
the status entries report "NOLB" instead of "UP", and the HTML page uses
darker colors. As a complement, write "DOWN" in bold red on the backend
if it has no server left for load balancing.
2007-11-30 12:04:38 +01:00
Willy Tarreau
0ebe106ef1 [MEDIUM] secure the calling conditions of ->set_server_status_{up,down}
It's not always obvious for the callers of set_server_status_{up,down}
whether the new state really is up or down. Some flags as well as the
effective weight have to be considered. Let's ensure that those functions
perform the necessary check themselves so that if the state transition
cannot be performed, at least everything is updated as required.
2007-11-30 11:11:02 +01:00
Willy Tarreau
48494c0c5c [MEDIUM] implement "http-check disable-on-404" for graceful shutdown
When an HTTP server returns "404 not found", it indicates that at least
part of it is still running. For this reason, it can be convenient for
application administrators to be able to consider code 404 as valid,
but for a server which does not want to participate to load balancing
anymore. This is useful to seamlessly exclude a server from a farm
without acting on the load balancer. For instance, let's consider that
haproxy checks for the "/alive" file. To enable load balancing on a
server, the admin would simply do :

  # touch /var/www/alive

And to disable the server, he would simply do :

  # rm /var/www/alive

Another immediate gain from doing this is that it is now possible to
send NOTICE messages instead of ALERT messages when a server is first
disable, then goes down. This provides a graceful shutdown method.

To enable this behaviour, specify "http-check disable-on-404" in the
backend.
2007-11-30 10:41:39 +01:00
Willy Tarreau
c7dd71ae5b [MEDIUM] change server check result to a bit field
A server check currently returns either -1 or 1. This is not very
convenient to enhance the health-checks system. Let's use flags
instead.
2007-11-30 08:33:21 +01:00
Alexandre Cassen
5eb1a9033a [MEDIUM] New option http_proxy
Hello,

You will find attached an updated release of previously submitted patch.
It polish some part and extend ACL engine to match IP and PORT parsed in
HTTP request. (and take care of comments made by Willy ! ;))

Best regards,
Alexandre
2007-11-29 15:43:32 +01:00
Willy Tarreau
3168223a7b [MINOR] move the load balancing algorithm to be->lbprm.algo
The number of possible options for a proxy has already reached
32, which is the current limit due to the fact that they are
each represented as a bit in a 32-bit word.

It's possible to move the load balancing algorithms to another
place. It will also save some space for future algorithms.
2007-11-29 15:38:04 +01:00
Willy Tarreau
980b7d35c6 [TESTS] merge test-fwrr.cfg to validate dynamic weights 2007-11-28 14:23:32 +01:00
Willy Tarreau
18baa9d646 [TESTS] include filltab25.c to experiment on FWRR for dynamic weights
This is the 25th version of this test program. Merge it to ensure it
does not get lost.
2007-11-28 14:23:29 +01:00
Willy Tarreau
b625a085d8 [MAJOR] implement the Fast Weighted Round Robin (FWRR) algo
This round robin algorithm was written from trees, so that we
do not have to recompute any table when changing server weights.
This solution allows on-the-fly weight adjustments with immediate
effect on the load distribution.

There is still a limitation due to 32-bit computations, to about
2000 servers at full scale (weight 255), or more servers with
lower weights. Basically, sum(srv.weight)*4096 must be below 2^31.

Test configurations and an example program used to develop the
tree will be added next.

Many changes have been brought to the weights computations and
variables in order to accomodate for the possiblity of a server to
be running but disabled from load balancing due to a null weight.
2007-11-28 14:23:17 +01:00
Willy Tarreau
5dc2fa660c [MINOR] add a weight divisor to the struct proxy
Under some circumstances, it will be useful to be able to have
a server's effective weight bigger than the user weight, and this
is particularly true for dynamic weight-based algorithms. In order
to support this, we add a "wdiv" member to the lbprm structure
which will always be used to divide the weights before reporting
them.
2007-11-28 14:23:13 +01:00
Willy Tarreau
2069704492 [MEDIUM] differentiate between generic LB params and map-specific ones
Since the introduction of server weights, all load balancing algorithms
relied on a pre-computed map. Incidently, quite a bunch of map-specific
parameters were used at random places in order to get the number of
servers or their total weight. It was not architecturally acceptable
that optimizations for the map computation had impact on external parts.
For instance, during this cleanup it was found that a backend weight was
seen as 1 when only the first backup server is used, whatever its weight.

This cleanup consists in differentiating between LB-generic parameters,
such as total weights, number of servers, etc... and map-specific ones.
The struct proxy has been enhanced in order to make it easier to later
support other algorithms. The recount_servers() function now also
updates generic values such as total weights so that it's not needed
anymore to call recalc_server_map() when weights are needed. This
permitted to simplify some code which does not need to know about map
internals anymore.
2007-11-28 14:23:10 +01:00
Willy Tarreau
be68e6a437 [MEDIUM] ebtree: include config.h for REGPRM*
It's mandatory that all sources share the same defines for REGPRM*,
so let's include config.h for this.
2007-11-28 14:23:07 +01:00
Willy Tarreau
f56fd8a285 [BUILD] make ebtree headers multiple-include compatible
ebtree did not support being included multiple times.
2007-11-28 14:23:05 +01:00
Willy Tarreau
e6d2e4dbdf [MINOR] merge ebtree version 3.0
Version 3.0 of ebtree has been merged in but is not used yet.
2007-11-28 14:20:44 +01:00
Willy Tarreau
30e7101137 [OPTIM] small optimization on session_process_counters()
It was possible to slightly reduce the size and the number of
operations in session_process_counters(). Two 64 bit comparisons
were removed, reducing the code by 98 bytes on x86 due to the lack
of registers. The net observed performance gain is almost 2%, which
cannot be attributed to those optimizations, but more likely to
induced changes in code alignment in other functions.
2007-11-26 20:22:47 +01:00
Krzysztof Piotr Oledzki
583bc96606 [MEDIUM] continous statistics
By default, counters used for statistics calculation are incremented
only when a session finishes. It works quite well when serving small
objects, but with big ones (for example large images or archives) or
with A/V streaming, a graph generated from haproxy counters looks like
a hedgehog.

This patch implements a contstats (continous statistics) option.
When set counters get incremented continuously, during a whole session.
Recounting touches a hotpath directly so it is not enabled by default,
as it has small performance impact (~0.5%).
2007-11-26 20:21:47 +01:00
Willy Tarreau
5df518788d [BUG] fix missing parenthesis in check_response_for_cacheability
Parenthesis were missed when code was moved to this function.
This results in non-cacheable transactions not being ignored.
2007-11-26 20:16:53 +01:00
Willy Tarreau
1fbe4932fc [BUG] missing header names in raw stats output
qlimit, pid, iid and sid were missing from the raw stats output
2007-11-26 16:15:35 +01:00
Willy Tarreau
2815664277 [BUG] relative_pid was not initialized 2007-11-26 16:13:36 +01:00
Willy Tarreau
dcd4771b3d [MINOR] stats: report numerical process ID, proxy ID and server ID
It is very convenient for SNMP monitoring to have unique process ID,
proxy ID and server ID. Those have been added to the CSV outputs.
The numbers start at 1. 0 is reserved. For servers, 0 means that the
reported name is not a server name but half a proxy (FRONTEND/BACKEND).

A remaining hidden "-" in the CSV output has been eliminated too.
2007-11-04 23:35:08 +01:00
Willy Tarreau
e6b989479c [MAJOR] create proto_tcp and move initialization of proxy listeners
Proxy listeners were very special and not very easy to manipulate.
A proto_tcp file has been created with all that is required to
manage TCPv4/TCPv6 as raw protocols, and provide generic listeners.

The code of start_proxies() and maintain_proxies() now looks less
like spaghetti. Also, event_accept will need a serious lifting in
order to use more of the information provided by the listener.
2007-11-04 22:42:49 +01:00
Willy Tarreau
3acf8c3da8 [MINOR] add a generic unbind_all_listeners() primitive
Most protocols will be able to share a single unbind_all_listeners()
primitive. Provide it in protocols.c.
2007-11-04 22:42:49 +01:00
Willy Tarreau
1a64d16720 [MINOR] add a generic delete_listener() primitive
Most protocols will be able to share a single delete_listener()
primitive. Provide it in protocols.c, and remove the specific
version from proto_uxst.
2007-11-04 22:42:49 +01:00
Willy Tarreau
b648d6383b [MINOR] add a generic unbind_listener() primitive
Most protocols will be able to share a single unbind_listener()
primitive. Provided it in protocols.c.
2007-11-04 22:42:49 +01:00
Willy Tarreau
8eebe5ea40 [MEDIUM] unbind_listener() must use fd_delete() and not close()
It is important that unbind_listener() calls fd_delete() to remove
a file descriptor, because only this one can update the fdtab and
the maxfd entries.
2007-11-04 22:42:48 +01:00
Willy Tarreau
dabf2e2647 [MAJOR] added a new state to listeners
There was a missing state for listeners, when they are not listening
but still attached to the protocol. The LI_ASSIGNED state was added
for this purpose. This permitted to clean up the assignment/release
workflow quite a bit. Generic enable/enable_all/disable/disable_all
primitives were added, and a disable_all entry was added to the
struct protocol.
2007-11-04 22:42:48 +01:00
Willy Tarreau
6fb42e0694 [MINOR] add an options field to the listeners 2007-11-04 22:42:48 +01:00
Willy Tarreau
8ced9a4b91 [MEDIUM] simplify error path in event_accept()
The error path in event_accept() was complicated by many code
duplications. Use the classical unrolling with the gotos. This
fix alone reduced the code by 2.5 kB.
2007-11-04 22:41:52 +01:00
Willy Tarreau
396d2c6782 [MINOR] avoid calling some layer7 functions if not needed
Small optimization: in some cases, it's not interesting to call
functions which are dedicated to checking the cache headers or
cookies. Avoid calling them when not necessary.
2007-11-04 22:41:49 +01:00
Willy Tarreau
816eb54e9b [MINOR] adjust error messages about conflicting proxies
It's not easy to report useful information to help the user quickly
fix a configuration. This patch :
  - removes the word "listener" in favor of "proxy" as it has been
    used since the beginning ;

  - ensures that the same function (hence the same words) will be
    used to report capabilities of a proxy being declared and an
    existing proxy ;

  - avoid the term "conflicting capabilities" in favor of "overlapping
    capabilities" which is more exact.

  - just report that the same name is reused in case of warnings
2007-11-04 08:14:25 +01:00
Krzysztof Piotr Oledzki
6eb730ded9 [MEDIUM] Implement and use generic findproxy and relax duplicated proxy check
This patch:
 - adds proxy_mode_str() similar to proxy_type_str()
 - adds a generic findproxy function used with default_backend/setbe/use_backed
 - rewrite default_backend/senbe/use_backed to use introduced findproxy()
 - relaxes duplicated proxy check
 - changes capabilities displaying from "%X" to "%s" with a call to proxy_type_str()
2007-11-04 08:14:20 +01:00
Willy Tarreau
2ee30416af [BUILD] disable warning about localtime_r on Solaris
Solaris only declares localtime_r() if _REENTRANT is defined. Update
the makefile to silent the warning.
2007-11-03 16:18:11 +01:00
Willy Tarreau
a7e76142a1 [MEDIUM] make default_backend work in TCP mode too
The default_backend did not work in TCP mode since there was no
header state to assign the backend. This causes much trouble when
configs are created by copy-paste.

The solution was to fix the way the backend is assigned upon accept().
A wrong contimeout assignment was fixed too.
2007-11-03 14:28:39 +01:00
Willy Tarreau
0173280bfa [MEDIUM] introduce the "url_param" balance method
Some applications do not have a strict persistence requirement, yet
it is still desirable for performance considerations, due to local
caches on the servers. For some reasons, there are some applications
which cannot rely on cookies, and for which the last resort is to use
a parameter passed in the URL.

The new 'url_param' balance method is there to solve this issue. It
accepts a parameter name which is looked up from the URL and which
is then hashed to select a server. If the parameter is not found,
then the round robin algorithm is used in order to provide a normal
load balancing across the servers for the first requests. It would
have been possible to use a source IP hash instead, but since such
applications are generally buried behind multiple levels of
reverse-proxies, it would not provide a good balance.

The doc has been updated, and two regression testing configurations
have been added.
2007-11-01 23:05:09 +01:00
Willy Tarreau
a0cbda61a7 [MINOR] externalize the "balance" option parser to backend.c
A new function "backend_parse_balance" has been created in backend.c,
which is dedicated to the parsing of the "balance" keyword. It will
provide easier methods for adding new algorithms.
2007-11-01 23:04:55 +01:00
Willy Tarreau
1a20a5d1b2 [CLEANUP] group PR_O_BALANCE_* bits into a checkable value
In preparation for newer balance algorithms, group the
sparse PR_O_BALANCE_* values into layer4 and layer7-based
algorithms. This will ease addition of newer algorithms.
2007-11-01 23:01:49 +01:00