C00kieMonsta / nest-socket-redis

Example demonstrating how to use Redis with Nest socket communication. Very useful when dealing with stateless session. Storing basic data on Redis in-memory database to easily retrieve websocket session

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebSocket with Nest and Redis

Components

  1. In-memory database (Redis)
  2. Propagator (Redis)
  3. WebSocket client (Socket.io)

Context

Whenever using a stateless back-end and using WebSockets for real-time communication, you need a way to keep track of session in some way. Redis Pub/Sub can help in keeping track of client connecting to you back, without having to create a session.

The idea of stateless application is thougher to setup but easier to maintain. It also makes the scaling up way easier when containerizing your application on hundreds of containers that can be easily disposed.

Redis will support in managing and keeping track of open connections (WebSockt connections).

fb-websocket-flow

About

Example demonstrating how to use Redis with Nest socket communication. Very useful when dealing with stateless session. Storing basic data on Redis in-memory database to easily retrieve websocket session


Languages

Language:TypeScript 98.1%Language:Dockerfile 1.9%Language:Shell 0.0%