Menu

Post image 1
Post image 2
Post image 3
Post image 4
1 / 4
0

How Redis Actually Works — RAM, Single Thread, and the Expiry Behavior Nobody Explains

DEV Community·Piyush Kumar Singh·about 1 month ago
#uIBtutSw
Reading 0:00
15s threshold

A RAM read takes about 100 nanoseconds. A disk read — even on a modern SSD — takes around 100,000 nanoseconds. That single gap explains most of Redis’s speed, before it does a single thing clever. Friend’s Link But RAM alone isn’t the full story. The other half is a design decision that looks like a limitation on paper — and turns out to be one of the smartest choices in the codebase. More on that in a moment. Here’s what’s actually happening inside Redis when your app talks to it. Why is Redis so fast? The first reason is obvious once you hear it: Redis keeps everything in RAM. Your PostgreSQL instance, however well-tuned, writes to disk. Redis doesn’t. Every key lives in memory, which is why a GET on a Redis key can return in under a millisecond even under load. There’s no disk seek, no page cache miss, no I/O wait. But here’s where most explanations stop — and they shouldn’t. Single-threaded — and that’s the point Redis processes one command at a time—one thread. No parallelism, no concurrency.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More