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.

  1. Deploy the client change behind a setting (an environment variable that picks Memcached or KiviDB), so you can switch back without a deploy.
  2. Size and start KiviDB. Check INFO memory and the eviction policy.
  3. Optional: copy. Run the copy program shortly before the switch, so the remaining TTLs are close to right.
  4. Switch the setting, a slice of traffic at a time.
  5. Watch keyspace_hits and keyspace_misses in INFO stats, the load on your database, and your application's latency.
  6. 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.
  7. 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.
  8. When nothing has read from Memcached for a full TTL, turn it off.