The webpage background is based on PHP + Mysql + Redis + Nginx. Would you like to know how many people view the webpage online at the same time (view the webpage at the same time)? What is the solution?
The webpage background is based on PHP + Mysql + Redis + Nginx. Would you like to know how many people view the webpage online at the same time (view the webpage at the same time)? What is the solution?
Reply content:
The webpage background is based on PHP + Mysql + Redis + Nginx. Would you like to know how many people view the webpage online at the same time (view the webpage at the same time)? What is the solution?
Here is an open-source component http://www.workerman.net/web-sender developed based on workerman for very precise statistics of online users
Effect:
You can collect statistics on the number of online users in real time or even the number of pages currently opened by users. The effect is as follows:
For Online demo, see http://www.workerman.net/at the bottom of the page
Principle
The principle is that after the page is opened, js establishes a persistent connection with the socket of the server. When the page sends a uid login request through this socket connection, the server will know which user the connection belongs, if all your connections are closed, the user is offline. At the same time, based on the number of socket connections, you can know the number of pages on the entire website. Because the socket can monitor Connection events and disconnection events in real time, the data is very real-time. The server uses workerman, which is not polling and has high performance.
Server usage
After the download, go to the command linephp start.php start -d
The startup interface is similar to the following:
Client usage