Skip to content
Peter Goldstein edited this page Dec 7, 2021 · 1 revision

Memcached commands are generally structured as a synchronous request and reply. That is, the interaction typically looks like:

  1. The user of the client calls a method on the client
  2. The client translates that method call into a request to send to memcached
  3. The request is sent to memcached via the network
  4. Memcached formulates a response
  5. The response is processed by the client, and translated to a set of return values for the method

This is a blocking process - that is, until the response is received and processed, additional memcached commands cannot be sent. Moreover, depending on the network situation, appreciable latency may be introduced in the process. Even if it only takes O(1 msec) to send a request and receive a response from memcached, that means that setting one million items will take ~1000 seconds - or over 10 minutes. This is less than ideal for some situations.

To address this limitation Dalli's quiet mode (aka multi mode) allows the client to perform storage and arithmetic operations in a "fire and forget" style. Requests are formulated and sent to memcached in "no reply" mode - which means that memcached will only generate a response packed in the case of an error. The caller does not block on a response from memcached, and hence requests can be enqueued as fast as the underlying socket allows us to write.

In practice this allows us to process a large number of memcached requests much, much faster than the above blocking interaction would allow.

The primary downside of this mode is that errors returned by memcached are ignored. While it would in theory be possible for Dalli to track requests using the "opaque" token supported by memcached requests, it currently doesn't have that functionality. So instead any errors generated and returned by memcached are ignored and the response packets are cleared at the end of the block.

The second downside is that we are unable to use certain commands in this mode. Any command whose primary purpose is to get the response value (e.g. get, gats, version, stats) cannot be used in quiet mode because we don't process the response packet. Note that we can still use some commands (e.g. set) that would return a response value normally, if we're ultimately less concerned about the response value than about the 'side effect' of the command.

When used judiciously, quiet mode can substantially improve application processing time.