Answer the question
In order to leave comments, you need to log in
What to choose for real-time update: Node.js, Comet or Ajax?
Hello, I have a question about the choice of technology.
There is a working site written in Yii , recently there was a need to create a page with a table that displays data from the MySQL database.
There is a project administrator who enters information into this database table.
It is necessary to implement push notifications, and adding new data to the displayed table for all users viewing this page. It is necessary that this happens as quickly as possible, ideally if the update takes place in real-time.
At the moment, only Apache is installed on the server , it is possible to install nginx, node.js.
Googling, I came up with several options with which you can implement this.
Options that came to mind (the cons that came to light during a cursory examination):
1. The first most frontal one is to fasten ajax and send a request to the database every second.
Cons: the number of requests to the database, the number of requests to the server
2. The same ajax, only the data from the database is cached in an html file (or memcache) using cron, thereby reducing the number of requests to the database
Cons: the number of requests to the server
3. Use Comet server, to establish long polling connections
Cons : Load on the server with more connections
4. Use phpDaemon
Cons : did not have time to study.
5. Use node.js
Cons: since the project is working, written in php, there may be problems with the simultaneous operation of apache and node.js
6. Use nginx-push-stream-module for long polling connection
Cons: did not have time to study.
It is clear that if only 1 person were viewing the page at the same time, then the most primitive method could be used, but what if the number of simultaneous unique visitors is 50 / 500 / 5000?
I would like to hear competent time which of the options:
The most optimal with a load of 100-200 uniques?
Which is the easiest to maintain?
What is the most resistant to loads (can withstand more than 3000 simultaneous connections)?
Ormaybe all these are absolutely stupid decisions , and I'm looking in the wrong direction, I will be glad for any information, or at least a direction in which it is worth digging.
Answer the question
In order to leave comments, you need to log in
Node.js, Comet or Ajax sounds hot, red or heavy.
On the issue, I advise you to use node.js + some kind of socket.io, faye. Hang the push server on a separate port so as not to proxy it through Apache. These libraries will allow you to effectively solve your problem.
> 4. Use phpDaemon
phpDaemon implements both long polling and websockets, which you somehow don't consider, although sockets are the most obvious here. If your project is already written in PHP, then your choice will most likely be between different PHP solutions, for reasons of ease of support. There are quite a few such solutions. You can try phpDaemon, if you like it, leave it. It is quite bulky compared to many analogues, but it is already quite stable, unlike more lightweight and simple options.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question