4 ms·
Anything PHP and you going to have bad time once you need concurrency. This time will come sooner or later.
by phplovesong 1y ago
Anything PHP and you going to have bad time once you need concurrency. This time will come sooner or later.
- CharlesW 1y agoRequest-level concurrency has always scaled well. As for lightweight concurrency, have you worked with PHP Fibers? https://medium.com/@binumathew1988/leveraging-php-fibers-for-concurrent-web-scraping-a-real-world-example-5fce41baf9c7 https://medium.com/@binumathew1988/leveraging-php-fibers-for...
- phplovesong 1y agoPHP Fibers does not do anything on its own. Its basically just syntax for generators, to be used with various external runtimes. This means in a vanilla PHP setup when i do something like this: $a = new Fiber(function () { sleep(2); // block Fiber::suspend(); return null; }); $b = new Fiber(function () { sleep(2); // block Fiber::suspend(); return null; }); // Start execution $a->start(); $b->start(); // ... later in code wait for both executions to finish $a->resume(); $b->resume(); // Total execution time is not 2 seconds, but 4 I need an additional runtime to support real concurrency. I also need a separate async IO library to handle blocking. This is usually a showstopper for most PHP still out there. And just annoying on so many levels.
- misiek08 1y agoThe best, most popular serverless platform? There are stacks much worse than PHP, like JVM for example ;) It (JVM) is getting better lately, for example with virtual threads, but still in same resources you can handle much more traffic via PHP and it can be hosted virtually on every hosting!
- phplovesong 1y agoNot sure why you say JVM is "worse" than PHP. It handles most real world workloads with no problem and is probably one one the most fine tunes VMs out there. It supports concurrency out of the box. That said JVM is only a target, so if Java is not your cup of tea, you are free to pick and choose from any of the various JVM languages, like Clojure, Kotlin, Scala etc.