Skip to content

Use cooperative scheduling in request handling by enabling swoole coroutine hooks for IO functions #9

@Rastusik

Description

@Rastusik

Is your feature request related to a problem? Please describe.
Current architecture of the swoole bundle expects the swoole http server process to handle exactly one request at once. I would like to enable cooperative scheduling by enabling the swoole IO functions coroutine hooks to be able to handle multiple requests concurrently, as the usage if Swoole was intended by design.

Describe the solution you'd like
The bundle should have a configuration option (e.g. cooperative_scheduling) which would enable concurrent request processing. I'm currently doing research and figuring out how to do it, I've identified these pin points:

  • to be able to use standard Syfony and Doctrine code, Swoole hooks for PHP IO functions need to be enabled (https://www.swoole.co.uk/docs/modules/swoole-coroutine-enableCoroutine)
  • a context manager for stateful Symfony services in DI container needs to be implemented (something like this https://www.swoole.co.uk/article/isolating-variables-with-coroutine-context)
  • maybe there should be some kind of concurrent request limiter implemented so php wouldn't run out of memory, but I'm not sure yet... or at least the default memory limit should be higher as usual, because in this mode, only one swoole web process should be sufficient to squeeze out the complete performance of a CPU core instead of multiple processes in the current implementation

Describe alternatives you've considered
I don't see any alternatives here, except the current implementation, feel free to discuss

Additional context
Nope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions