Chapter 14 checkpoint

A distributed key-value cache

Every question from this chapter’s lessons, grouped by the lesson that teaches it. Answer each one right to finish; you can try again whenever you like.

0 of 17 answered right

14.1 Requirements, estimates and the query cache

0 of 5 answered right
Open the lesson
Question 1
Each cache entry is 270 bytes, and there are 10 billion queries a month. If every query were unique and kept, how much would a month add, in TB?

Answers within 5% count, in any unit you choose.

Question 2
Using 400 requests per second ≈ 1 billion a month, how many requests per second do 10 billion queries a month average out to?
RPS

Answers within 5% count.

Question 3
A client sends one Redis command, waits for the reply, then sends the next, over a link with a 0.5 ms round-trip time. At most how many commands per second can it complete?
commands/s

Answers within 2% count.

Question 4
What does Redis pipelining change?

Question 5
Which data structure does the primer’s LRU cache use?

14.2 Memory: slab allocation, calcification and jemalloc

0 of 4 answered right
Open the lesson
Question 6
A Memcached server’s workload switched from small items to larger ones. Now it evicts recent large items constantly, even though plenty of memory sits in pages assigned to the small-item class. What is happening, and what fixes it?

Question 7
With Memcached’s default growth factor of 1.25, about what fraction of a chunk can be wasted in the worst case, as a percentage?
%

Answers within 5% count.

Question 8
A 1 MB Memcached page (1,048,576 bytes) belongs to the class with 120-byte chunks. How many chunks does it hold?
chunks

Answers within 1% count.

Question 9
Why is a Redis string of up to 44 bytes cheaper to store than a longer one?

14.3 Partitioning: consistent hashing and hash slots

0 of 4 answered right
Open the lesson
Question 10
Keys are placed with hash(k) mod N\text{hash}(k) \bmod N over 10 servers. One fails, leaving 9. What percentage of keys move to a different server?
%

Answers within 3% count.

Question 11
A cache uses consistent hashing with many points per server. Growing from 10 servers to 12, about what percentage of keys move?
%

Answers within 5% count.

Question 12
Why does libketama hash each server to 100–200 points on the ring instead of one?

Question 13
In Redis Cluster you need one multi-key command over a user’s profile and orders. How should you name the keys?

14.4 Replication, failover and client routing

0 of 4 answered right
Open the lesson
Question 14
Match each Redis Cluster reply to what the client should do.

Question 15
Three Sentinels watch a Redis primary, with the quorum set to 2. What does the quorum decide?

Question 16
A partition cuts the Redis primary off together with some clients, which keep writing to it. Sentinel promotes a replica on the other side. When the partition heals, those writes are gone. What bounds this loss?

Question 17
Put the steps of a Sentinel failover in order.
  1. 1
    It promotes that replica, and clients get +switch-master
  2. 2
    Enough Sentinels agree: objectively down
  3. 3
    A Sentinel wins a majority vote to lead the failover
  4. 4
    It picks a replica by priority, then replication offset, then run ID
  5. 5
    A Sentinel marks the primary subjectively down