7

I am currently making an online multiplayer chess game. I was wondering if it would be appropriate to user triggers to log in every movement.

Then, using nodejs I would repetitively check the trigger table and update the visual for both players & observers.

Since I only need to make changes in the database, the visual aspect would follow up automaticly (using the recurring function to check changed data in the database). The goal of this would be to seperate the visuals from the logic involved to make the game.

Would any of you recommend this technique or its simply a no go?

Kaii
  • 20,122
  • 3
  • 38
  • 60
Louis
  • 375
  • 1
  • 5
  • 12

1 Answers1

7

You describe a possible technical solution for your task. But i strongly recommend NOT to do so.

This will not scale very well - it adds a lot of overhead and load to both your database and application server.

There are other lightweight possibilities that scale much better:

  • use a message queue like (for example) redis with the node_redis client. It has built-in pubsub semantics.
  • abstract your database calls and push all database updates to the message queue, too.
  • instead of using a "recurring" function (AJAX poll) to get status updates, you could use a HTTP streamer like jquery-stream or jquery-socket for example. This avoids the overhead of opening a new HTTP connection for each client update.
  • use the event-driven features of nodejs on the server side to push new events to the client connection.
Community
  • 1
  • 1
Kaii
  • 20,122
  • 3
  • 38
  • 60
  • I forget to mention that I am using nowJS ( socket library ). By using this, the only occurring pool will be the server doing it twice per second to check for updates. Once an update is found it will be pushed to all users via a socket request. Even if there are a thousand user's eventually, the database will still be pooled at the same rate, only by the server. Would this have an impact on your recommendation? Thanks for you help. – Louis Apr 25 '12 at 06:57
  • @Louis you will still have the (avoidable) load on the database server and file system. – Kaii Apr 25 '12 at 07:21
  • What solution would you recommend to someone not using Node.js, but rather PHP? – timetofly Apr 17 '14 at 01:44