PHP is known as a single-threaded language, meaning it can only execute one task at a time within a single process. However, Laravel provides a rob...
For further actions, you may consider blocking this person and/or reporting abuse
There is something called Laravel Octane you must checkout it works well with high-powered application servers, including FrankenPHP, Open Swoole, Swoole, and RoadRunner. Octane boots your application once, keeps it in memory, and then feeds it requests at supersonic speeds.
Thanks for your suggestion. I will definitely look into it.
PHP itself is single threaded but most httpd servers are multi-threaded.
Perfect! To deep on any tech is the best way to learn and develop itself. Congrats!!!
Thank you for sharing this
What about fibers? Is it not used by Laravel to achieve multiparalelism?
Actually no, php fiber is not a multi-paralelism. It just helps you to stop a function's execution and later resume it. It doesn't run in background or in a separate thread. And when you resume a fiber function it runs synchronously in the main PHP process.
I would prefer calling it concurrency instead of parallelism.
Based on my understanding of the two concepts, I believe parallelism is the most-suited word:
Each spun worker executes "just" one task per time and they do so in parallel.
This is different from a concurrent operation where you have "just" one worker executing various tasks but toggling between them as each task runs into an operation, say, a network call, that cannot be resolved in that same moment (but will be, later).
The same worker keeps toggling/switching until all the tasks are executed eventually
In parallelism, you have processes like this:
worker 1
o – o – o – o
worker 2
o – o – o – o – o – o
In concurrency, you have a process like this:
worker 1
(where "o" signifies the executed task, and "–' represents the current path of execution)
Let me know if this makes any sense.
Nicely explained !!
Thank you for your kind words! It's something that has confused me in the past, so it feels great to be able to articulate the difference to another person
I get your point and totally agree for modern systems and simplified explanation.
Here's my view: Technically speaking, I think it depends on the system. As long as each worker runs on its own CPU at the same time, it is real parallelism. If you have only one CPU, there is no parallelism, but you can achieve it looking the same with concurrency. Note, that even multi-threading may still be concurrency, the OS handles it for us.
Ah, thank you for elaborating. I like your point about how the deciding factor is the no of CPUs. It's intuitive and easier to understand
ReactPHP reactphp.org/
Actually you can do this in native php with pheanstalk (php library for beanstalkd queue management) ... Just run the php watcher script using supervisor.
Good
Perfect 🔥