Closed assertchris closed 6 years ago
Great idea! I'd like to take the "advocate" role for this. I'm not familiar enough with async PHP to volunteer for co-maintainer.
@assertchris if this is mostly aimed at being a sort of architectural module, perhaps it might be a good idea to add a simple example module with a use case to go along with it - something like a live comments system, etc. Thoughts?
@assertchris still keen on doing this?
Please look at Swoole PHP extension:
https://www.w3c-lab.com/php-7-1-swoole-v1-9-5-vs-node-js-benchmark-test-php7-swoole-beats-node-js/
The light benchmark server handles 200k+ requests / second on a normal box, the range of 12x more than a nodejs async server.
Imagine a completely async server based on that, that would then route the isolated processes via the silverstripe event stack? It could also just layer next to it, but I assume the ORM and file read/write parts (at least, being the biggest IO bottlenecks) would need to be refactored to work async.
And there is also ReactPHP https://reactphp.org/
I find myself in a spot where I don't have time to pursue this. Someone else can pick it up, if it interests them. Until then, I think it best to close the issue.
silverleague/silverstripe-async
Specification: https://silverleague.github.io/draft/silverstripe-async
Why?
SilverStripe has a traditional, synchronous execution model. Except for QueuedJobs, no other supported module offers anything nearly useful for implementing asynchronous execution in places where an application could use it.
A module – which offers an event loop, web sockets, and sane parallel execution – could allow for more interesting and useful extensions to the CMS. This would make things like multi-user editing, presence, parallel queue execution, and DataObject push hooks trivial to implement.
Details
I propose we use Amp. It requires
^7.0
, which would become the required version for this module. It provides a mature event loop, promise, and web socket implementations. It also offers a parallel execution model that depends on Pthreads or PCNTL.I suggest we abstract the parallel execution code, and base the first version on
exec
instead (as this will already be used for the initial CronTask (event loop daemon).Functionality