Imagine your application makes thousands of queries to the same database. All this traffic generates latency, CPU load, disk load, and increases costs. In such scenarios, cache comes in: an ultra-fast memory (RAM) layer that stores recent results to avoid repeated database queries.

Instead of reading from disk (which can take tens or hundreds of milliseconds), the cache responds in microseconds. In practice, using cache allows the application to do much more "cheap" work in memory and very few expensive operations on the database.

For example, imagine a gaming site with 1 million visits per second displaying results. Without cache, that would be 1 million SELECTs on SQL. With Redis configured with a short TTL (e.g., 3s), Redis would handle about 60 million queries per minute, and only ~30 SQL queries would be executed, resulting in a drastic reduction in load. In other words, with a cache you go from "1,000,000 expensive operations" to "1 expensive operation + 999,999 cheap RAM accesses".

Redis is one of the most common tools for caching. It stores data in pure RAM memory, providing responses at nanosecond latencies.

Various benchmarks show that a typical database query takes in the range of 50–200 ms, while the same operation on Redis takes < 1 ms. In real situations, MySQL typically handles 500–1,000 queries per second, but a Redis server can exceed 100,000 operations per second on the same machine. Queries with multiple joins that took ~120 ms drop to ~0.8 ms on Redis. In the end, adding cache drastically reduces latency and increases system throughput by 10–50× (or more). That's why "almost everything on the internet" relies on Redis or similar for caching.