Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add to the documentation behaviors section some information regarding: tcp_keepalive, retry_timeout. #273

Open
trevorboydsmith opened this issue Nov 5, 2021 · 0 comments

Comments

@trevorboydsmith
Copy link

trevorboydsmith commented Nov 5, 2021

in the documentation there is no mention of the behavior "tcp_keepalive". this behavior is important and necessary when running in a kubernetes or docker-compose scenario because the connection goes through something that monitors for dead connections and the thing that monitors for dead connections has a timeout of like 15 minutes or something.

so i set the memcached behavior "tcp_keepalive" to 300 to ensure that my connecitons do not get cut by the networking thing.

for more better description of the "networking thing" see zulip/zulip#12711 which describes some about pika and also mentions the pylibmc.

my request: please add to the documentation some information regarding the "tcp_keepalive".

also i noticed there was missing a mention of "retry_timeout". please add that to the documentation too. (if you do not set this value to something like 5... does the client just error out on the first error?)


for the tcp keepalive to work you also need to set the "tcp_keepidle" value. unfortunately your python code does not expose this feature from the underlying c library. so for now i have a patch that i wrote.

diff --git a/src/_pylibmcmodule.h b/src/_pylibmcmodule.h
index cee9772..36a28bb 100644
--- a/src/_pylibmcmodule.h
+++ b/src/_pylibmcmodule.h
@@ -202,6 +202,7 @@ static PylibMC_Behavior PylibMC_behaviors[] = {
     { MEMCACHED_BEHAVIOR_TCP_NODELAY, "tcp_nodelay" },
 #if LIBMEMCACHED_VERSION_HEX >= 0x00044000
     { MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, "tcp_keepalive" },
+    { MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, "tcp_keepidle" },
 #endif
     { MEMCACHED_BEHAVIOR_HASH, "hash" },
     { MEMCACHED_BEHAVIOR_KETAMA_HASH, "ketama_hash" },

and i do a pip download --no-binary=pylibmc pylibmc. extract, cd, patch, build, install.

tcp_keepalive is boolean value. see https://man7.org/linux/man-pages/man7/socket.7.html section SO_KEEPALIVE.

tcp_keepidle is integer time in seconds. see https://man7.org/linux/man-pages/man7/tcp.7.html section on TCP_KEEPIDLE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant