Jump to content

Download Counter


DSGameMaker

Recommended Posts

Hi folks,

 

I know there's 2 ways you can build a download counter: A file to which you write, or writing to a specific row/field in a MySQL field.

 

As this php page for recording the download is going to be used alot, like 1000 times a day, it has to be efficient.

 

All it will be doing is: Take the number of current downloads (GET), add 1, save it (SET). I know file handling and I/O is slow but how slow is SQL in comparison.. is it worth creating an entire query and session for that or use the filesystem.

 

I would like your advice on which is better to use.

 

 

Regards,

- James

Link to comment
Share on other sites

A real database will be better. It'll support concurrent writes better because if the table is locked, it'll just queue queries like this:

UPDATE files SET downloads=downloads+1 WHERE id=42;

 

If you are writing to a file you risk getting incorrect results with many concurrent requests.

 

If you are concerned about making too many writes to the database, you can use something like APC to cache download counts and only write the changes to the database every 10 minutes for instance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.