Redis

less than 1 minute read

Redis -

redis, pub/sub : Also, light weight messaging bus

In Memory database

  • High read/write throughput
  • Low latency
  • Db size cannot be more than the (available) memory (trade-off)

In-memory data structures are much easier to implement than the on-disk counterparts

Redis is SINGLE THREADED

Multithreaded application, in order to use all CPU Cores, it requires locks and other synchronization mechanisms

In Redis, the single thread won’t get blocked waiting for the completion of each request individually with the help of IO Multiplexing

With I/O Multiplexing, the OS allows a single thread to wait on many socket connections simultaneously. (select() or poll() system calls)

On linux -> epoll is performant variant of IO Multiplexing (support thousands of connections at constant time)

Drawback : it does not leverage all the CPU Cores od the modern hardware (Redis was released in 2009)

https://github.com/ByteByteGoHq/system-design-101?tab=readme-ov-file#why-is-redis-so-fast

Redis use cases

https://www.youtube.com/watch?v=a4yX7RUgTxI