How does php display the number of visits per second?

Source: Internet
Author: User
How does php display statistics on the number of visits per second? How does php implement statistics on the number of accesses per second?


Reply to discussion (solution)

For help ..............................

Analyze web server logs

Insert a record for each access and analyze the record, or query the log as described above.

At the php layer, the number of visits increases once (for example, using memcache for storage), and the number of accesses increases once (for example, 500 times)
On the web server layer, view access logs. for example, nginx uses the access. log file by default.

Analyze web server logs


I would like to ask, how can I call log files in php and how can I analyze them? Sample code

At the php layer, the number of visits increases once (for example, using memcache for storage), and the number of accesses increases once (for example, 500 times)
On the web server layer, view access logs. for example, nginx uses the access. log file by default.


How can I analyze nginx log files in php? How?

Locate the log file and confirm that php has access to the log file.
Paste the last 10 lines of log files

At the php layer, the number of visits increases once (for example, using memcache for storage), and the number of accesses increases once (for example, 500 times)
On the web server layer, view access logs. for example, nginx uses the access. log file by default.


How can I analyze nginx log files in php? How?



192.168.1.115--[26/Nov/2015: 08: 45: 18 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 45: 41 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 53: 18 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 53: 22 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 55: 00 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 55: 01 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 08: 55: 03 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 09: 16: 04 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "200 70"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 09: 16: 29 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "200 70"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 09: 16: 31 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "200 70"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 09: 16: 42 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1332"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"
192.168.1.115--[26/Nov/2015: 09: 53: 10 + 0800] "GET/cloud/V1/post_irimg HTTP/1.1" 200 61 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0"


This is part of my log file. I don't know how to analyze it. why does this help to count the number of visits? how can this problem be solved?

For the first line
192.168.1.115--[26/Nov/2015: 08: 45: 18 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"

Where
192.168.1.115 is the visitor's ip address.
[26/Nov/2015: 08: 45: 18 + 0800] indicates the access time.
"GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "request method and request url
404 is the http response type (404 indicates that the request target is not found)
1333 unclear meaning (but does not affect your analysis)
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0" is the visitor's device

You can extract the access time for statistics.

For the first line
192.168.1.115--[26/Nov/2015: 08: 45: 18 + 0800] "GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "404 1333"-"" Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0"

Where
192.168.1.115 is the visitor's ip address.
[26/Nov/2015: 08: 45: 18 + 0800] indicates the access time.
"GET/admin/d1/get_id? Pid = 13333333333 HTTP/1.1 "request method and request url
404 is the http response type (404 indicates that the request target is not found)
1333 unclear meaning (but does not affect your analysis)
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 40.0) Gecko/20100101 Firefox/40.0" is the visitor's device

You can extract the access time for statistics.



Oh, thank you! how can we achieve that? How can we compare them?

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.