-
Notifications
You must be signed in to change notification settings - Fork 465
Quiet Mode
Memcached commands are generally structured as a synchronous request and reply. That is, the interaction typically looks like:
- The user of the client calls a method on the client
- The client translates that method call into a request to send to memcached
- The request is sent to memcached via the network
- Memcached formulates a response
- 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 deletion operations in a "fire and forget" style. Requests are formulated and sent to memcached in "no reply" mode - which means that memcached will not generate a response. 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.
Dalli's set_multi and delete_multi methods use quiet mode internally to pipeline their requests. This is what makes them significantly faster than calling set or delete in a loop:
# Fast — uses quiet mode to pipeline all sets
dc.set_multi({ 'k1' => 'v1', 'k2' => 'v2', 'k3' => 'v3' }, 3600)
# Fast — uses quiet mode to pipeline all deletes
dc.delete_multi(['k1', 'k2', 'k3'])See Advanced Features for more on bulk operations.
The primary downside of quiet mode is that errors returned by memcached are not surfaced to the caller. Requests are sent without waiting for individual acknowledgements, so any errors generated by memcached for those requests are silently ignored.
The second downside is that certain commands cannot be used in this mode. Any command whose primary purpose is to get a response value (e.g. get, version, stats) cannot be used in quiet mode because the response is not processed. Note that we can still use commands like set that would normally return a response, if we're ultimately less concerned about the response than about the side effect of the command.
When used judiciously, quiet mode can substantially improve application processing time.
-
General Information
- Requirements and Integrations
- Installing memcached
-
Getting Started
- Using Dalli with SSL/TLS
- Setting up a Development Environment
- Configuring the Dalli Client
- Configuring Servers
- Client Options
- Advanced Features
- Operational Considerations