Choose of IP Address Database Structure

admin

Administrator
Staff member
I have a project in mind to work on. I need to know how many users is currently on-line and viewing my web page.

What I have in mind is recording the surfer's IP address and datetime in MySQL database whenever my web page is being displayed via a script call.

I assume the surfer will stay on my page for 5 minutes. The script will check the database and see if the datetime expires in 5 minutes.

When the script is called, it will verify all IP entries and remove the expired IP entries. It'll verify to see if the surfer's IP is in the database. If yes, the current datetime will be added to the associated IP entry. If not, a new entry and current datetime will be added.

My current problem is what's the structure of database that I'm going to choose for the representation of IP address in this particular project.

I have the following ideas in mind:

Assuming the IP address is of a.b.c.d

1. storing the IP address as a large number of (a*256*256*256)+(b*256*256)+(c*256)+d
2. storing the IP address as 4 fields of integer
3. storing the IP address as a string

I'm wodnering which one of the above will be most efficient and optimize the performance for my particular project listed above?

I'm expecting 1,000,000 of calls per day to this script, which implies there would be a significant amount of add/remove/query to my database.

If you have a even better sollution or ideas in mind, please don't hesitate to let me know.
 
Back
Top