Cut over: migrate from Memcached to KiviDB
A cache can be switched with no downtime, because a miss is never an error.
A cache can be switched with no downtime, because a miss is never an error.
- Deploy the client change behind a setting (an environment variable that picks Memcached or KiviDB), so you can switch back without a deploy.
- Size and start KiviDB. Check
INFO memoryand the eviction policy. - Optional: copy. Run the copy program shortly before the switch, so the remaining TTLs are close to right.
- Switch the setting, a slice of traffic at a time.
- Watch
keyspace_hitsandkeyspace_missesinINFO stats, the load on your database, and your application's latency. - Invalidation. While both caches serve traffic, a write that deletes or updates a cached key must do it in both, or a reader on the old cache can see stale data. If your application invalidates on write, make it do both until the switch is complete.
- Rollback: flip the setting back. Memcached still holds what it held; it
only missed the writes made while it was out of use. Flush it
(
flush_all) before switching back if those could leave stale entries. - When nothing has read from Memcached for a full TTL, turn it off.