Redis internals and performance
You study Redis data structure encodings, the event loop, the memory allocator and persistence internals, measure and fix latency and memory problems, and write server-side logic with Redis Functions.
Level 501 · 14 lessons · 12 practice labs
Lessons
Internals
- The single-threaded event loop and I/O threads
- Encodings: listpack, intset, skiplist
- The memory allocator and fragmentation
- fork, copy-on-write and persistence
- Short task: interpret a memory report
Latency
- Sources of latency
- LATENCY DOCTOR and the latency monitor
- Finding big and hot keys
- Pipelining and redis-benchmark
- Short task: explain a sudden latency spike
Server-side logic
- Redis Functions
- Keyspace notifications
- Client-side caching
- Capstone: get Redis ready for ten times the traffic
Practice labs
- See a key's internal encoding: Watch OBJECT ENCODING change as hashes, lists and sets grow from small to large.
- Tune encoding thresholds and measure memory: Change listpack thresholds, measure memory for a million small hashes and pick the best setting.
- Fix memory fragmentation: Interpret the memory report of a server with a high fragmentation ratio and bring it down with active defragmentation.
- Turn on the latency monitor: Enable the latency monitor with a threshold and record the spike caused by a large delete.
- Explain latency caused by fork: Link the latency rise during a snapshot to fork time and copy-on-write memory.
- Find the source of a sudden latency spike: Find and fix the cause of a spike that happens daily at the same time with LATENCY DOCTOR, SLOWLOG and system metrics.
- Take a baseline with redis-benchmark: Measure requests per second for GET and SET at different client counts.
- Cut round trips with pipelining: Send 10,000 commands one by one and pipelined, measure the difference and find a good batch size.
- Find a hot key and spread its load: Find traffic piling onto one key with --hotkeys and spread reads with copies or a local cache.
- Watch expiring keys with notifications: Enable keyspace notifications and catch expiring session keys with a listener.
- Turn a Lua script into a Redis Function: Move a Lua script the app sends every time into a persistent function library and call it with FCALL.
- Prepare for ten times the traffic with client-side caching: Reduce and measure reads reaching the server using client-side caching and invalidation messages.
About this course
You study Redis data structure encodings, the event loop, the memory allocator and persistence internals, measure and fix latency and memory problems, and write server-side logic with Redis Functions.
What you will learn
- Internals
- Latency
- Server-side logic
Prerequisites
You should be experienced in the topics of the same path up to level 401.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 501; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.