Real time Log watcher web based application with websocket and Redis-adapter.
- Client
- Server : server.js , socket.js 2a. services : tailService.js
- log : contain the main app.log file which needs to be tracked.
- log generator : generator.js : responsible for generating content in app.log file in every n sex interval
To start with frontend:
- npx create-react-app client-logger.
- npm i socket.io-client // need to google once before running this command.
- To start the project: npm start
To start with backend:
- npm i
- npm i cors
- npm i express
- npm i socket.io (Need to google)
- npm i redis (Need to google)
- npm i @socket.io/redis-adapter (Need to google)
- To run the project : node server.js / nodemon server.js (npm i nodemon)
To run the redis server over docker, run this command: docker run -p 6379:6379 redis
- We use a Socket.IO adapter with Redis mainly for scaling the WebSocket system across multiple server instances. Without it, code works only if there is one Node.js server.
- Redis acts as a central message broker.
- Instead of local event broadcasting, use Redis pub/sub to synchronize events across servers.
- Redis is good for this because it is: -> very fast -> in-memory -> supports pub/sub -> simple to integrate
- "In production we would use Redis adapter for horizontal scaling."