4 ms·
The point made in the article: * resource leaks are non-existent Can not be emphasized enough imo. The amount of absolute ridiculous levels of pain instigated
by dingdingdang 1y ago
The point made in the article:
* resource leaks are non-existent
Can not be emphasized enough imo. The amount of absolute ridiculous levels of pain instigated by expecting a core code loop to run -forever- and doing so well while being written for some web project or other is just too much to fathom. Just use PHP and serve the request. Then let it die. Then serve a new request.
- ksenzee 1y agoThis is, indeed, my favorite feature of the language.
- nine_k 1y agoIt's not a language feature but a runtime feature. There's no reason why JS or Python or Java could not be run like that.
- ksenzee 1y agoThe language itself, though, does absolutely have this assumption built in. If you want to run it in an endless loop, you’ll have issues.
- EGreg 1y agoNo you won’t, other runtimes like Swoole, FrankenPHP, and even amphp let you do that, just spin up a PHP process. I wouldn’t recommend them, though.
- ksenzee 1y ago“You’ll have issues” was my way of saying “I wouldn’t recommend them.” IMO if you want to run in a loop, pick a language where that’s the standard practice.
- dingdingdang 1y agoI find some of the language around FrankenPHP difficult to parse - is FrankenPHP always in loop mode (ala ReactPHP) or is it simply an option? I can't tell.. my gut reaction upon reading the intro material is that they "simply" replaced Apache/Nginx with Go's inbuilt, and much lighter, server structure and that PHP itself is left to run completely isolated as per usual?! edit: indeed https://frankenphp.dev/docs/classic/ https://frankenphp.dev/docs/classic/ indicates normal runner capability similar to Apache.
- mekazu 1y agoAgree that it’s good to get the certainty of zero memory leaks (assuming there’s no associated bugs in apache) but it’s not that hard to write code that doesn’t cause memory leaks for stateful apps as long as you are able to follow certain simple principles and avoid bugs in the third party libs you use.
- nedt 1y agoIt‘s called „shared nothing“. Also makes scaling easier and you can restart processes anytime without impact, because every request starts at zero anyway.
- donatj 1y agoIt also makes scaling across multiple servers an absolute breeze when there's no shared state across requests to worry about.
- majorbugger 1y agoThis has got to be a joke. What if you need any kind of in-memory cache? Or in general, any kind of application maintaining state, for, say, performance reasons?
- EGreg 1y agoPHP has apcu as the in-memory cache And it’s not a joke, PHP is actually the most secure runtime environment out there for web hosting, PRECISELY because of the shared-nothing architecture. Faster runtimes exist, like Swoole and recently FrankenPHP, to do evented programming like Node JS. But let me tell ya — you risk all kinds of leaks, both of unfreed memory and of secrets, across requests. It ain’t worth it most of the time!
- frizlab 1y agoWhere I worked we had to reboot the php-fpm servers periodically because they had a leak…
- johntash 1y agoOne of my biggest issues with php was the number of imports and file reads involved. It made running something like wordpress _really_ slow on slow disks or over nfs. I don't remember apcu or opcache helping much for that because I think it still did a stat on every file iirc. For single-file php apps or just not using a big framework, it's not really a problem.
- spdionis 1y agoYou can configure opcache to never stat unless it's reloaded
- johntash 1y agoHuh, well that sounds like it would have been useful. It's been at least 10 years since I did any php dev work, but maybe I'll find an excuse to use it again for something.
- dingdingdang 1y agoNot only can you configure it to never stat; it has also been on by default since PHP 5.5 afaicr