ICJ
ICJ

Reputation: 307

Update database to keep information updated in real time - PHP

My current project is heavily database driven, and 90% of the content is user generated. There are a variety of things that need to be updated and the previous solution was a cron job but it did not offer real-time data for the users. ( things like site rank, etc. need to be updated in real time )

The current plan is to load the site and place a function in the footer to execute an update for the database. In order to decrease the workload and prevent each user from experiencing long load times i limit each update to look back for 24 hours only, and each user only handles a specified limit so 5 updates or so per user. This fires up every time the page is loaded.

The previous version of this site had 15,000 members within 2 months. After some thinking I realized this would probably be enough BUT when the member base increases this may not be the best option. I am wondering if there is a way to execute a php script after the page has loaded or something similar. Instead of creating a long list of cron jobs it would be better ( in my head ) to just force server to execute a php script to check and implement updates. This way the user does not experience long load times and i can keep data up to date.

None of the data that is being updated will be required to be viewed in real time on the screen. This is all just to update the database to keep ranks and other things updated in real time, instead of updating say every hour etc.

Upvotes: 3

Views: 2203

Answers (1)

VeeeneX
VeeeneX

Reputation: 1578

Websocket version

You can use WebSocket, it can handle this things such as Dynamic updating things, online users and many more. You can use Node.js with SocketIO or go,python and php there are many of these.

Some Examples:

Ajax version

If you don't want to pay hosting for your application for node.js, then this is best solution you will have a lot of requests on Database, but there is a problem when should be code updated? That's a good question. It depends on you after hour,minute,second. And after so many request's your database will be destroyed.

Upvotes: 1

Related Questions