How can I view the number of concurrent online users on a webpage?

Source: Internet
Author: User
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?
  1. 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:
  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.