K
K
Konstantin Kitmanov2014-02-04 19:50:35
Node.js
Konstantin Kitmanov, 2014-02-04 19:50:35

Periodic events in the application on node.js

I am writing a zero-playing game (something like Godville ), respectively, for each character, whether he is logged in or not, it is necessary to generate a game event every N minutes.
It would be possible to get by with setTimeout, but when the application crashes/restarts, it will be necessary to restore all this, and for all players at once.
It would be possible through cron, but then the calculation of the outcome of the event will occur again for all players at once, and this is somehow stressful for the server, IMHO. Creating a separate cron task for each player is somehow wild.
The third option is that one application generates events and calculates their outcome, while the second only reads from the database and shows the players their adventures, but in this case it is not clear how to send a push notification to the user.
I really don’t like any method, besides, there is a feeling that there are already tried and tested solutions for this kind of tasks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-02-04
Protko @Fesor

there are no problems with push notifications - there are websockets and socket.io. I liked the third option better, although it can be done in the form of a single application using things like webworker-threads .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question