Before you start: migrate from Memcached to KiviDB
Check these in your code and your Memcached settings:
What your application uses
Check these in your code and your Memcached settings:
- Client library and its serializer. Most Memcached clients serialize
objects for you and record how in the item's client flags (pymemcache's
serde, spymemcached's transcoders, PHP's
Memcachedextension). The Redis client you move to will serialize differently, or not at all. - Item size. Memcached's limit is 1 MB per item by default (
-Iraises it, up to 1024 MB). A KiviDB string can be up to 512 MB (proto-max-bulk-len), so only a Memcached run with-Iabove512mcan hold items too big to move as they are. - Expiry times above 30 days. Memcached reads an expiry over 2,592,000 seconds as an absolute Unix time. Find these before you translate the calls.
cas,incr,decr,append,prepend. Each changes slightly; see below.- How many servers. If your client spreads keys over several Memcached servers, decide whether KiviDB will be one server or a cluster.
- Eviction. Memcached evicts by LRU when memory is full. To behave the same
way, set KiviDB's
maxmemoryandmaxmemory-policy allkeys-lru. The default (noeviction) refuses writes when memory is full instead.
Which KiviDB build
The default build is enough: nothing in this move needs Lua. Use the tls or
full build if clients connect over TLS. On KiviDB Cloud, set the eviction
policy under Configuration → Eviction and persistence
(Backups and persistence). There you can also
turn persistence off, as Memcached has none.
Sizing
Read Memcached's own numbers:
printf "stats\r\nquit\r\n" | nc memcached.internal 11211 | grep -E "curr_items|bytes |limit_maxbytes"
bytes is the memory the items use now; limit_maxbytes is the -m limit.
Give KiviDB at least bytes plus room to grow. If Memcached is always full and
evicting (evictions in stats keeps rising), size by the hit rate you want,
not by the old limit.