M
M
MuscleC2017-10-16 09:57:04
Redis
MuscleC, 2017-10-16 09:57:04

Is it right to distribute processes like this?

Hi all. I'm doing a NodeJS + Redis project. I
started for self-study. The goal was to understand web sockets, to build a real-time application for gathering people in a certain lobby for games.
Initially, everything was in one process, where there were:
- a socket server
- all subscribe to several Redis instances
- an express-based API
- requests to another API
- Timers - various functions that work with a delay - `setInterval` - for example, automatic selection something, provided that a group of users did not have time to make a choice on their own.
After refactoring, I split the project into separate processes:
1. Socket server + redis sub to access the data bus that needs to be sent via sockets.
2. API server + redis sub
3. API client + redis sub
4. Redis sub - for other tasks.
And completely removed `setInterval`, replacing it with `Redis EXPIRE`.
The goal was to rid the Socket Server process of everything not related to sockets. In fact, the entire load fell on Redis to send commands to various processes and store temporary data.
I manage processes using pm2.
1. Isn't it too much, what do you think?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question