3 ms·
> php scripts are meant to be run once per request memory leaks are not an issue Yes, and that’s exactly why I said that PHP is awful for background processing
by mikl 3y ago
> php scripts are meant to be run once per request memory leaks are not an issue
Yes, and that’s exactly why I said that PHP is awful for background processing, because there the process ideally runs continuously, or at least as long as there’s data to process. With PHP, I have to continuously re-spawn the processes to keep the memory leaks in check.
If your application is so simple that it doesn’t need to process data outside of the request/response cycle, I’m sure PHP is fine.
And sure, you can compensate for PHPs lack of async processing by spawning more processes, but that makes the RAM bloat problem even worse.
- trog 3y agoWe have scripts that have been running continuously for probably years at a time with none of these issues. The only time they stop is when servers are rebooted for updates. We actually had a big argument about building them like this for exactly the reasons you mentioned though - the preference for me and some others was to run them as once off's from cron, specifically to avoid the possibility of memory issues. Our tech lead wanted them to run as services (I think to improve responsiveness primarily). I didn't think it would work as well, but history has proven that it worked fine. I can't say it was better - it took a while to work out the kinks - but these things have been happily running for over a decade with basically zero issues relating to memory leaks, etc. They're not super complicated but not trivial either.