Will querying and updating a Database every 3 seconds for multiple users cause any server problems?

Viewed 80

This isn't so much a question of how to do something but a question of SHOULD i do it.

I'm tracking the amount of time a video is watched by updating the database with a start and end time when a video is started or ended. The problem is that if a user just closes the window without letting the video end or manually clicking pause or stop, then I wont get an end time logged.

So, what I'm currently doing in development is running a function every 3 seconds that that uses AJAX and PHP to update the database with an end time - that way if someone closes the window I have a rough end time give or take 3 seconds.

My question is Should I do this? I don't know much about hardware and I'm worried that if Multiple people are watching the video, all sending updates to the DB every 3 seconds, that It could cause some issues.

Am I essentially going to DDOS attack my own website?

Any advice would be greatly appreciated

1 Answers

Well since it is a problem that can be addressed in many ways, the main thing is to investigate some details of the platform (RAM, NET, I / O disk), to be able to anticipate any future problems, now if constantly updating data will affect performance of the systems that occupy the same server, on the other hand you could choose to make updates less frequently and the data is saved in a table or temporary files, then you program a cron style process to update your database at night.

Related