Optimising session key storage in Redis
on Deliveroo, Performance, Redis
Tracking authenticated user sessions can be implemented in Redis using setex
with some serialised JSON. It works pretty well until you have to cope with millions, or even tens of millions of sessions where the memory usage and performance can suffer. By using Redis data structures more effectively we can achieve a 70% reduction in memory usage, at the cost of both code and conceptual complexity. Is it worth it?