The invention relates to the technical field of computer networks, and discloses a method for real-time statistics of the number of network users. According to the method for real-time statistics of the number of network users, network messages, meeting various protocols, in the traffic are analyzed thoroughly on the premise that all the network traffic of various terminal users in some region is obtained, key information is extracted, appropriate structures are selected according to the requirement of statistics, corresponding user attributes are added, assembling storage is carried out, and real-time performance of the query is improved due to the fact that a local cache technology is adopted; due to the fact that a user time ageing technology is used for correspondingly dealing with the situation that offline messages of dynamic users are lost, and the situation that static users do not have offline messages; in order to ensure accuracy of user statistics, a system provides interfaces for the users, the user range, namely the IP section, of the region is set through the interfaces, and interference caused by the transit traffic to statistics is ensured; when access is carried out on static IPs for the first time, the asynchronous processing mode is adopted, and the real-time response speed of the system is increased.