Understand the Redis Adapter

The Socket.IO Redis adapter uses Redis Pub/Sub to distribute events between multiple Socket.IO server instances.

Each server connects to Redis using two clients:

  • Publisher client: Publishes events to Redis channels.
  • Subscriber client: Receives events published by other server instances.

When one server broadcasts an event to a room, the Redis adapter distributes the broadcast to other Socket.IO servers.

Those servers then deliver the event to their locally connected clients.

This allows users connected to different application instances to communicate through the same logical Socket.IO rooms.

Redis Adapter Components

Publisher

Sends messages

Publishes Socket.IO adapter messages to Redis.

Subscriber

Receives messages

Subscribes to Redis Pub/Sub channels.

Redis

Message distribution

Distributes adapter messages between application instances.

Socket.IO Adapter

Cross-instance broadcasts

Connects Socket.IO broadcasting behavior to Redis Pub/Sub.

Socket.IO Redis Adapter Architecture
Key Takeaways
  • Redis Pub/Sub distributes events between server instances.

  • Publisher and subscriber clients perform different roles.

  • The Redis adapter extends broadcasting across instances.