summaryrefslogtreecommitdiff
path: root/proxy.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-03-04 21:50:28 -0800
committerdormando <dormando@rydia.net>2023-03-26 16:48:37 -0700
commit6c80728209acdb46629db8db3868d59d627ec33e (patch)
tree1628e77e962c0b0037ab225a444828d99ae3b8a5 /proxy.h
parente0fa1fe46aeb9e405cb58234f6016b2c48a10777 (diff)
downloadmemcached-6c80728209acdb46629db8db3868d59d627ec33e.tar.gz
proxy: add request and buffer memory limits
Adds: mcp.active_req_limit(count) mcp.buffer_memory_limit(kilobytes) Divides by the number of worker threads and creates a per-worker-thread limit for the number of concurrent proxy requests, and how many bytes used specifically for value bytes. This does not represent total memory usage but will be close. Buffer memory for inbound set requests is not accounted for until after the object has been read from the socket; to be improved in a future update. This should be fine unless clients send just the SET request and then hang without sending further data. Limits should be live-adjustable via configuration reloads.
Diffstat (limited to 'proxy.h')
-rw-r--r--proxy.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/proxy.h b/proxy.h
index 0ab3b91..24a5ea0 100644
--- a/proxy.h
+++ b/proxy.h
@@ -195,6 +195,8 @@ typedef struct {
lua_State *proxy_state;
void *proxy_code;
proxy_event_thread_t *proxy_io_thread;
+ uint64_t active_req_limit; // max total in-flight requests
+ uint64_t buffer_memory_limit; // max bytes for send/receive buffers.
pthread_mutex_t config_lock;
pthread_cond_t config_cond;
pthread_t config_tid;
@@ -497,6 +499,9 @@ typedef struct {
mcp_pool_be_t *pool; // ptr to main->pool starting offset for owner thread.
} mcp_pool_proxy_t;
+// utils
+bool proxy_bufmem_checkadd(LIBEVENT_THREAD *t, int len);
+
// networking interface
void proxy_init_event_thread(proxy_event_thread_t *t, proxy_ctx_t *ctx, struct event_base *base);
void *proxy_event_thread(void *arg);