Creating a live checker web application in PHP, JS, CSS and HTML?

I want to create a live, checker-like application that will work as follows: several icons / avatars, such as a surface, will be displayed on this chessboard. I want to have a command prompt under this board or some other interface that will allow them to control a specific avatar and make it perform preform operations. Several users will use it at a time, and I can all see other changes / user actions on the chessboard.

What interests me: what is the best way to do this? I have my approach to HTML, CSS and JS, but not my data storage method. I know that using PHP, I have a choice to use: file storage, MYSQL or another method. I need to know which is better, because I do not want the server timeout, bad response time or some other problem, especially in this case, because the actions will be performed every two seconds or so by these several users.

I already did similar things before, but I want to hear how others will deal with this (tips, etc.) from more experienced programmers.

+6
source share
2 answers

Sounds like a great project for node.js!

To clarify, node.js is a server side javascript implementation. What you want is a comet-based application (a web-based client application that receives server transfers, instead of the client constantly polling the server), which is for node.js.

Traditional ajax encourages your clients to query the server for data. This creates huge overhead for both the client and server. By allowing the server to push requests directly to the client without re-requesting the client, it solves the overhead problem and creates a more flexible interface. This is achieved by making asynchronous client connections on the server and only returning when the server has something to answer. As soon as the server responds with data, another connection is immediately created and held by the server again until the data is ready to be sent.

You can do the same thing with PHP, but I'm not so familiar with applications like PHP and Comet.

The number of users and the cost of hosting will be reproduced in files with DB options. If you plan on more than a few users, I will stick with the database. There are some NoSQL options available there, but in my experience, MySQL is much faster and more reliable than these options.

Good luck with your project!

http://en.wikipedia.org/wiki/Comet_%28programming%29

http://www.nodejs.org/

http://zenmachine.wordpress.com/2010/01/31/node-js-and-comet/

http://socket.io/ - abstracts the level of communication with your customers based on their capabilities ( LongPolling , WebSockets , etc.)

+7
source

MySQL and XCache !!!!

Make sure you use the predefined statements, so MySQL does not need to compile SQL again. Memtables can also be used to use memory

Of course, use indexes appropriately.

If "gamestate" is not so important, you can even store everything in XCache. Remember that XCache does not persist data persistently (after restarting Apache)

0
source

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


All Articles