Is it bad to change max_execution_time in PHP to something like 5 mins in order to make long poll (comet) push requests?
-
26-10-2019 - |
Question
I am trying to make a semi-realtime notification system sort of like on Facebook and for that I am looking forward to using long polling instead of mindless polling (polling every N seconds).
Yes, I am not using Apache, I am on Nginx which can handle this type of polling.
Now a question arose, all the tutorials I read about this subject matter of long polling show examples where the ajax request timeout in 30-50 seconds if no data is returned and then poll again, that made no sense to me because previously I used to poll the server every 30 seconds to check for notifications, how does the long polling make the situation any better? it will still be reconnecting every 30 - 50 seconds.
For that reason I considered that it might be an option to change max_execution_time from the default 60 to 300 or 400, then poll with a request that waits for at least 5 mins before timing out and reconnecting.
Can I expect any bad side effects of doing so? Is this approach flawed? Or is there a better approach?
Thank you.
Solution
The better approach would be using a backend optimized for tasks like that, e.g. node.js
.
However, if you want to use PHP, there's no reason against raising the max execution time.