Redis learnings for today
Redis isn't a database that "uses some RAM" — it IS RAM.
Every byte in your key and value is a byte of memory you pay for. No "just add disk." Your data has to fit in memory.
So 3 rules: make keys short, strip redundant fields, store nothing twice.
Here's the exact change that saved me GBs :
1-second stock candles. Key: stock:AAPL:1s, score = timestamp.
Before (~108 bytes): {"s":"AAPL","o":292.48,"h":292.49,"l":292.455,"c":292.465,"v":1373,"dv":null,"vw":292.484,"t":1781276855000}
After (~44 bytes): [292.48,292.49,292.455,292.465,1373,292.484]
What changed? → s is already in the key → t is already the score → dv was always null → killed the field names: JSON object → packed array
Same data. ~60% smaller.
At millions of rows/day, that's the difference between a 32GB box and a 16GB one. Your data model IS your infra bill.
What's the simplest optimization that saved you the most memory?