From 98634f0c7b8d6aff0086fef9fedd90ffc79abcc2 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Tue, 29 Oct 2013 23:30:51 -0400 Subject: [PATCH] MEDIUM: backend: Enhance hash-type directive with an algorithm options Summary: In testing at tumblr, we found that using djb2 hashing instead of the default sdbm hashing resulted is better workload distribution to our backends. This commit implements a change, that allows the user to specify the hash function they want to use. It does not limit itself to consistent hashing scenarios. The supported hash functions are sdbm (default), and djb2. For a discussion of the feature and analysis, see mailing list thread "Consistent hashing alternative to sdbm" : http://marc.info/?l=haproxy&m=138213693909219 Note: This change does NOT make changes to new features, for instance, applying an avalance hashing always being performed before applying consistent hashing. --- Makefile | 2 +- doc/configuration.txt | 84 +++++++++++++++++++++++++---------------- include/common/hash.h | 28 ++++++++++++++ include/types/backend.h | 6 +++ src/backend.c | 76 +++++++++++++++++++++++++------------ src/cfgparse.c | 18 +++++++-- src/hash.c | 61 ++++++++++++++++++++++++++++++ 7 files changed, 214 insertions(+), 61 deletions(-) create mode 100644 include/common/hash.h create mode 100644 src/hash.c diff --git a/Makefile b/Makefile index 2acaee4aa..4c30cc06c 100644 --- a/Makefile +++ b/Makefile @@ -637,7 +637,7 @@ OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocol.o \ src/stream_interface.o src/dumpstats.o src/proto_tcp.o \ src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \ src/acl.o src/sample.o src/memory.o src/freq_ctr.o src/auth.o \ - src/compression.o src/payload.o + src/compression.o src/payload.o src/hash.o EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \ $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ diff --git a/doc/configuration.txt b/doc/configuration.txt index ba8057fdf..643afd919 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2496,45 +2496,65 @@ grace