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