Is it fine to use AJAX to reload a page content in PHP every 0.5 second? Won't it impose any drawback on the performance? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it fine to use AJAX to reload a page content in PHP every 0.5 second? Won't it impose any drawback on the performance?

I am creating a social networking site in PHP where I need to display msgs of all the live people chatting with each other (just as we see in chatrooms). I am using JQuery AJAX functionality to fetch new msgs from the database of every user on the screen every half a second (0.5 second). I'm afraid if this could cause any performance issues later in my application. Won't it slow down my browser or crash the app when so many requests will be generated by the script every 0.5 sec for each user? Is there any better alternative?

24th Oct 2019, 2:10 AM
Abhishek Kumar Singh
Abhishek Kumar Singh - avatar
1 Answer
0
in my experience anything that loops can create massive load later on if there is more data involved. so it depends what you are doing every 0.5 seconds. if you are doing something that will increase as more users are involved then yes, it probably won't scale. I learned to try to avoid using loops if they are not needed.
24th Oct 2019, 5:20 AM
Nathan Stanley
Nathan Stanley - avatar