Help with Live Update data

Hi

I have a situation where I have to show some numbers on a php page. And that number must refresh its own to show the current one in the db.

Its like a product in the inventory. So if i am on the Buy page, I can see how many product is left, and this will be live. Means, if another user is online and buy 10 items, it automatically updates my page (without reloading) to show the number of that products left in the inventory.

I know that this can be done using AJAX. (Recall function once it is end etc.) But, my question is what of the following is better approach for this :

  1. Call AJAX function to get the current numbers left from the database. Means if there are 100 users, it will be 100 queries each second ?

  2. Have a cron job that will execute a php script to write the latest updated number in a text file on server, and this cron will run each second. Now, on the buy page, it will be an ajax function to read that text file and show the current numbers.

  3. Any other way that you may suggest ?

Please tell me what from the above sounds good ? Please consider that on the site there might be 100000s people at once.

Thanks & Best regards
ZH

:frowning: - Not a single response !