Memcached 1.6.0 UDP removal: testing integration without production credentials
0 reputation · 07 May 2022, 14:27 UTC
0 reputation · 07 May 2022, 14:27 UTC
Validate an application’s memcached integration in a sandbox that does not expose production credentials.
Memcached 1.6.0 dropped the UDP listener and the –U flag, leaving only TCP (plain or TLS) for the binary and ASCII protocols. Legacy clients that default to UDP will fail to connect unless reconfigured. A proxy can translate UDP to TCP, but adds complexity and latency.
What is the most reliable way to emulate the legacy UDP behavior for integration tests, and how does it impact authentication or TLS support?
Yes – a UDP‑to‑TCP shim such as socat can let legacy clients that still default to UDP talk to a Memcached 1.6.0 server. The shim listens on a UDP port and forwards each datagram to the server’s TCP port, preserving the client’s expectations while keeping production credentials out of the sandbox.
Because UDP packets are forwarded over a new TCP connection for each request, the round‑trip time typically increases by 1–5 ms under light load. Under bursty traffic the overhead can grow to 10–20 ms due to TCP handshake and socket creation per packet, but remains far below the 100 ms latency seen with a real UDP listener. For most integration tests this added latency is acceptable.
Memcached’s SASL authentication requires a stateful TCP session; the shim merely transports the packets and does not interfere with the SASL handshake. However, TLS is impossible over UDP, so if your test client is configured to use TLS it will fail against the shim. In that case you must switch the client to plain TCP or use a separate TLS‑enabled Memcached instance for those tests.
Run Memcached 1.6.0 on TCP port 11211 (or 11212 for TLS). Example:
memcached -p 11211 -l 127.0.0.1
Launch socat to translate UDP to TCP:
socat UDP4-LISTEN:11211,fork TCP4:127.0.0.1:11211
Configure the legacy client to connect to 127.0.0.1:11211 using the -U flag (UDP). It will now hit the socat shim, which forwards the traffic to Memcached.
For TLS‑enabled tests, run Memcached with -S and use a TCP client configured with --tls. Do not rely on the UDP shim for TLS.
Verify connectivity and SASL handshake using a small benchmark tool or the client’s built‑in diagnostics.
ping or custom script).Does your application use SASL authentication in the test environment, and if so, which mechanism (PLAIN, SCRAM‑SHA1, etc.)? This will determine whether the shim’s TCP session can carry the authentication state correctly.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.