mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-22 20:32:12 +00:00
haproxy public development tree
df187875da
In issue #648 a second problem was reported, indicating that some users mistakenly send the log to an FD mapped on a file. This situation doesn't even enable O_NONBLOCK and results in huge access times in the order of milliseconds with the lock held and other threads waiting till the watchdog fires to unblock the situation. The problem with files is that O_NONBLOCK is ignored, and we still need to lock otherwise we can end up with interleaved log messages. What this patch does is different. Instead of locking all writers, it uses a trylock so that there's always at most one logger and that other candidates can simply give up and report a failure, just as would happen if writev() returned -1 due to a pipe full condition. This solution is elegant because it gives back the control to haproxy to decide to give up when it takes too much time, while previously it was the kernel that used to block the syscall. However at high log rates (500000 req/s) there was up to 50% dropped logs due to the contention on the lock. In order to address this, we try to grab the lock up to 200 times and call ha_thread_relax() on failure. This results in almost no failure (no more than previously with O_NONBLOCK). A typical test with 6 competing threads writing to stdout chained to a pipe to a single process shows around 1000 drops for 10 million logs at 480000 lines per second. Please note that this doesn't mean that writing to a blocking FD is a good idea, and it might only be temporarily done on testing environments for debugging. A file or a terminal will continue to block the writing thread while others spin a little bit and lose their logs, but the writing thread will still experience performance-killing latencies. This patch should be backported to 2.1 and 2.0. The code is in log.c in 2.0, but the principle is the same. |
||
---|---|---|
.github | ||
contrib | ||
doc | ||
examples | ||
include | ||
reg-tests | ||
scripts | ||
src | ||
tests | ||
.cirrus.yml | ||
.gitignore | ||
.travis.yml | ||
BRANCHES | ||
CHANGELOG | ||
CONTRIBUTING | ||
INSTALL | ||
LICENSE | ||
MAINTAINERS | ||
Makefile | ||
README | ||
ROADMAP | ||
SUBVERS | ||
VERDATE | ||
VERSION |
The HAProxy documentation has been split into a number of different files for ease of use. Please refer to the following files depending on what you're looking for : - INSTALL for instructions on how to build and install HAProxy - BRANCHES to understand the project's life cycle and what version to use - LICENSE for the project's license - CONTRIBUTING for the process to follow to submit contributions The more detailed documentation is located into the doc/ directory : - doc/intro.txt for a quick introduction on HAProxy - doc/configuration.txt for the configuration's reference manual - doc/lua.txt for the Lua's reference manual - doc/SPOE.txt for how to use the SPOE engine - doc/network-namespaces.txt for how to use network namespaces under Linux - doc/management.txt for the management guide - doc/regression-testing.txt for how to use the regression testing suite - doc/peers.txt for the peers protocol reference - doc/coding-style.txt for how to adopt HAProxy's coding style - doc/internals for developer-specific documentation (not all up to date)