How to use Redis pub/sub to handle socket.io sessions across multiple instances ?

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • redis-socket-blog

  • Before going into the solution of the problem, let’s understand the technologies i have used along with some snippet of the actual code. I have written the server code in golang and i am using Postman as client. The two technologies i would like to brief you all are socket.io and Redis pub/sub. If you are already familiar with the concepts just glance through my description to better understand the blog and solution provided by it.

  • go-socket.io

    socket.io library for golang, a realtime application framework.

  • Socket.io helps in delivering messages to client in real time. Behind the scene socket.io creates a bi-directional channel between server and client therefore enabling bidirectional communication between web client and server. For demo code I have used a golang server therefor i have used a golang library called go-socket.io . Some advance socket.io concepts which you should be aware are channel, event, namespace and rooms.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Newman

    Newman is a command-line collection runner for Postman

  • Before going into the solution of the problem, let’s understand the technologies i have used along with some snippet of the actual code. I have written the server code in golang and i am using Postman as client. The two technologies i would like to brief you all are socket.io and Redis pub/sub. If you are already familiar with the concepts just glance through my description to better understand the blog and solution provided by it.

  • Socket.io

    Realtime application framework (Node.JS server)

  • Before going into the solution of the problem, let’s understand the technologies i have used along with some snippet of the actual code. I have written the server code in golang and i am using Postman as client. The two technologies i would like to brief you all are socket.io and Redis pub/sub. If you are already familiar with the concepts just glance through my description to better understand the blog and solution provided by it.

  • Redis

    Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

  • First of all let’s understand Redis. It is an in-memory data structure store which is used as a database, cache, message broker, and streaming engine. Redis pub/sub is one the features of Redis. You can get official documentation of Redis pub/sub here . Let me give you a brief on few of the concepts of Redis pub/sub. There are two components in Redis pub/sub first one is Publisher. Its function is to send message payload to a given channel/Topic. Subscribers, these subscribe/unsubscribe to a particular topic. A message sent to a topic by a publisher is received by all subscribers subscribed to that topic. Given figure explains the principle of Redis pub/sub.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts