Forum Moderators: coopster

Message Too Old, No Replies

MySQL or text file?

What's best for online counter with high traffic?

         

cameraguy

3:28 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Hello,

I wrote a web counter that tracks online visitors. Visits are recorded in a MySQL table. But I am considering switching to a text file.

The reason is that I am getting hundreds of simultaneous connections (I operate more than one counter on more than one site) and my server is under too much stress to keep up.

Would a cookie + text file based solution be better in my case?

Thank you for your expert advise.

Roberto

LeChuck

5:00 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



When you begin with high volume touching of the filesystem it can give you very high cpu load, just as with too many db connections.

The best option would probably be something in-memory so the disk filesystem wouldn't need to be touched. A bit outside my experience but...

Are you running this on your own linux server? You could try making a ramdisk and putting the counter files on it.

cameraguy

8:42 am on Jan 5, 2006 (gmt 0)

10+ Year Member



My server is hosted but yes, I am pretty sure it's running under Linux.

However, I have no idea what you mean... :(

Roberto

mm1220

9:00 am on Jan 5, 2006 (gmt 0)

10+ Year Member



Just use a text file with the number stored in it. This is the simplest solution. I highly doubt you could trouble a server too much, however with MySQL you might breach your host's maximum connections limit.

In other circumstances (i.e. not a simple counter) you could look into caching etc.