summaryrefslogtreecommitdiff
path: root/proxy.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-02-24 19:22:52 -0800
committerdormando <dormando@rydia.net>2022-02-24 22:34:33 -0800
commit2a903f04d1b395cd60c1b7357a9b733e19eb7973 (patch)
tree781e0544c035f590c0727aebbb52e129777af5e1 /proxy.h
parenta7b83d36ff7c6bbdb7783d352bb056554c83efcd (diff)
downloadmemcached-2a903f04d1b395cd60c1b7357a9b733e19eb7973.tar.gz
proxy: add ring_hash builtin
this is ketama-based, with options for minor compat changes with major libraries. does _not_ support weights. The weights bits in the original ketama broke the algorithm, as changing the number of points would shift unrelated servers when the list changes. this also changes backends to take a "name" specifically, instead of an "ip address". Though note if supplying a hostname instead of an IP there might be inline DNS lookups on reconnects.
Diffstat (limited to 'proxy.h')
-rw-r--r--proxy.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/proxy.h b/proxy.h
index f64952c..535ae8b 100644
--- a/proxy.h
+++ b/proxy.h
@@ -292,7 +292,7 @@ struct mcp_request_s {
};
typedef STAILQ_HEAD(io_head_s, _io_pending_proxy_t) io_head_t;
-#define MAX_IPLEN 45
+#define MAX_NAMELEN 255
#define MAX_PORTLEN 6
// TODO (v2): IOV_MAX tends to be 1000+ which would allow for more batching but we
// don't have a good temporary space and don't want to malloc/free on every
@@ -303,9 +303,6 @@ typedef STAILQ_HEAD(io_head_s, _io_pending_proxy_t) io_head_t;
#define BE_IOV_MAX IOV_MAX
#endif
struct mcp_backend_s {
- char ip[MAX_IPLEN+1];
- char port[MAX_PORTLEN+1];
- double weight;
int depth;
int failed_count; // number of fails (timeouts) in a row
pthread_mutex_t mutex; // covers stack.
@@ -327,6 +324,8 @@ struct mcp_backend_s {
bool stacked; // if backend already queued for syscalls.
bool bad; // timed out, marked as bad.
struct iovec write_iovs[BE_IOV_MAX]; // iovs to stage batched writes
+ char name[MAX_NAMELEN+1];
+ char port[MAX_PORTLEN+1];
};
typedef STAILQ_HEAD(be_head_s, mcp_backend_s) be_head_t;
@@ -455,6 +454,7 @@ int mcplib_request_ntokens(lua_State *L);
int mcplib_request_gc(lua_State *L);
int mcplib_open_dist_jump_hash(lua_State *L);
+int mcplib_open_dist_ring_hash(lua_State *L);
int proxy_run_coroutine(lua_State *Lc, mc_resp *resp, io_pending_proxy_t *p, conn *c);
mcp_backend_t *mcplib_pool_proxy_call_helper(lua_State *L, mcp_pool_t *p, const char *key, size_t len);