Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Proroutines (?) #84

Open
leocavalcante opened this issue Dec 14, 2020 · 1 comment
Open

Feature request: Proroutines (?) #84

leocavalcante opened this issue Dec 14, 2020 · 1 comment

Comments

@leocavalcante
Copy link
Member

leocavalcante commented Dec 14, 2020

Hi 馃憢

I was zapping my social feed when a suddenly found this: https://github.com/clue/reactphp-pq
Looks interesting because of the easiness it provides (Laravel surfs a lot on this), I mean...
I know it is "just" multi-processing and Swoole already does a really good job, but!!

What about and API that treats a new process like if its a new "Coroutine"?

A Proroutine (or a better name) is like a Coroutine, but it is actually a new process and all of this could be just a sugar, in the library, around Pool and Manager?
Then whatever is blocking, like unimplemented I/O protocols or CPU-bound tasks, you can delegate to a Proroutine instead of a Coroutine. With the proper disclaimer that a Proroutine is not arbitrary created like a green-thread/coroutine.

Procroutines looks cool as well.

@fakharksa
Copy link
Contributor

fakharksa commented Nov 7, 2022

@leocavalcante
Creating heavy OS-Processes, one merely for each Coroutine (where Coroutine is just an I/O-bound Asynchronous Task) is against the core philosophy / primitives of "Asynchronous Programming Paradigm", hence not highly Scalable, not cost-effective, not resource-efficient and low in Performance at scale.

The philosophy behind Coroutines is that "Multiple Coroutines (tasks) should be able to run within same OS-process, through an Event-loop in order to mimic as if light-weight (virtual-/green-) threads; also called as Fiber in modern Asynchronous Programming Paradigm. This is the reason why Coroutines are more easier-to- use/maintain, cost-effective and resource-efficient compared to multi-threading and multi-processing.

You can have multiple OS-Processes but each should be able to run multiple coroutines (Asynchronous/Concurrent/Non-blocking Tasks).

Note:

  1. Swoole allows you to delegate CPU-bound (long-running) Tasks to be delegated to separate OS-Processes called as Task Workers. Task Workers run Asynchronously by default (but can also be asked to execute Synchronously, if needed.)

  2. Apart from Task Workers, Swoole additionally allows to create multiple child Processes, but you should not use them as replacement to Coroutines; that is not a good idea as OS-Process is the heaviest thing for memory in Operating Systems, so it should be used efficiently with careful planning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants