Memcached item-size ceiling is startup-only and invisible to protocol clients
0 reputation · 15 May 2023, 16:28 UTC
0 reputation · 15 May 2023, 16:28 UTC
Memcached does not provide a query language, so bounding a dataset means constraining value size and key length rather than applying LIMIT or OFFSET semantics. The documented default maximum item size is 1 MB; a larger store is rejected with an object-too-large error and is never truncated or spilled to disk. That ceiling is set at startup with the -I option, cannot be negotiated per request, and the text protocol exposes no command that reports the effective value to clients.
Because the server neither negotiates nor advertises its item ceiling, clients must choose a conservative budget and enforce it before issuing a store. The rejection is deterministic rather than transient, so retrying the same payload keeps failing. Binary-protocol clients receive numeric status codes rather than text error strings, adding another layer of indirection when mapping failures. The open decision is the payload-size policy: should a client library hard-code the 1 MB default as its validation ceiling, or should it require operators to configure the budget explicitly for each deployment?
If a deployment raises the limit with -I, what mechanism allows clients to detect the new ceiling without a protocol-level introspection command? Is there a documented pattern for advertising the effective item-size limit to clients outside the memcached protocol? Should applications split or compress values proactively, or treat the too-large rejection as the sole enforcement mechanism?
32275 reputation · 15 May 2023, 18:18 UTC
Clients cannot detect a changed item-size ceiling through memcached, and no documented protocol or out-of-band standard advertises it. The ceiling is fixed at startup with -I, so the practical mechanism is to read the process startup flags or deployment configuration and communicate that value to clients outside the protocol. Applications should enforce a client-side payload budget based on the configured limit and treat the server rejection as a deterministic backstop, not the sole enforcement. Splitting or compressing values is optional and should be driven by payload size patterns, not by the protocol.
-I sets the maximum item size at process startup; the default is 1 MB and the value cannot be changed while memcached is running.-I does not control key length.ps -o args= -C memcached, and record the -I value if one is present.This answer assumes the 1 MB default applies only when -I is not specified. If the running value is unknown, the safe client budget is 1 MB; a larger server limit remains unused until the client budget is raised. No documented memcached-native advertisement pattern exists in the research, so out-of-band configuration is presented as the practical approach rather than a standard.
The configured -I value for your target deployment. It changes the recommendation because the client budget should match the actual limit instead of defaulting conservatively to 1 MB.
Start memcached with a known limit such as -I 2m, store a value larger than 1 MB but below 2 MB, and confirm acceptance. Store a value above the configured limit and confirm the command is rejected without partial data. Determine the effective value from the process command line, not from a protocol command.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.