MySQL design, statistics script execution interval time.
This post was last edited by Mumubangditu on 2014-03-29 19:56:24
I have an RSS program that I want to count: is the server of the other website subscribed to my RSS, or the ordinary customer opens the execution through the browser.
The idea now is to count the frequency at which each IP address is accessed to differentiate. If the server of another Web site subscribes to my RSS, it must be timed with an automated program, each execution interval is a constant, such as every 60 minutes, every 90 minutes.
$ip =$_server[' remote_addr '];
In this case, how to design MySQL database? This access time-last access time, last access time-previous access time, previous access time-previous access time (should also consider an error each time the script opens to finish may be plus or minus seconds) ... This situation is counted 5 times, presumably can be determined that the IP is an automatic program, the next time no more statistics.
------Solution--------------------
This post was last edited by xuzuning on 2014-03-29 20:07:08
Two fields: IP, Time (Unix timestamp)
Decision criteria: For the same IP (max (time)-min (time))/count (*) = AVG (Time)-min (time)
Algorithm basis: The nature of arithmetic progression
------Solution--------------------
In fact, you can also judge User-agent information.
------Solution--------------------
Determined to be server, it should be recorded in another table (example serverlist).
First, the version of the presenter is every time there is access and not determined whether the server, the IP and access time to write a table (example Accesslog). After each write, determine whether the server is accessed. (usually several times to be sure)
If yes, insert a record in serverlist and delete the accesslog corresponding IP record.
When this server re-access, first determine whether serverlist has this IP, if there is, do not write Accesslog.
------Solution--------------------
Registering access information, of course, is journal
Just insert, analysis and calculation usually requires only one update
If you do, you can also use the view
If you do not register as journal, you need select to locate and then update to modify
Finally, the analysis and calculation