Mysql: when to use triggers

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

Then, using nodejs, I periodically repeat the trigger table and update the visual image for both players and observers.

Since I only need to make changes to the database, the visual aspect will be automatically executed (using the repeating function to check the changed data in the database). The goal of this would be to separate visual effects from the logic involved in the game.

Can any of you recommend this technique or just won’t leave?

+6
source share
1 answer

You describe a possible technical solution for your task. But I highly recommend NOT to do this.

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

There are other lightweight features that scale much better:

  • use a message queue like (for example) redis with node_redis . It has built-in pubsub semantics.
  • draw your database calls and add all database updates to the message queue.
  • Instead of using a "repeating" function (AJAX polling) to receive status updates, you can use an 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-related nodejs functions on the server side to direct new events to the client connection.
+6
source

Source: https://habr.com/ru/post/914094/


All Articles