|  Download RoadRunner          
 High-performance PHP load balancer and process manager library for Golang. Library allows you to embed PHP code into Golang applications as managed pool of stateless workers. Features:
no external services, drop-in (based on Goridge)
load balancer, process manager and task pipeline
frontend agnostic (queue, REST, PSR-7, async php, etc)
works over TPC, unix sockets and standard pipes
automatic worker replacement and safe PHP process destruction
worker lifecycle management (create/allocate/destroy timeouts)
payload context and body
control over max jobs per worker
protocol, worker and job level error management (including PHP errors)
very fast (~250k calls per second on Ryzen 1700X over 16 threads)
works on Windows
 Installation:$ go get github.com/spiral/roadrunner
$ composer require spiral/roadrunner
 Examples:p, err := rr.NewPool(
    func() *exec.Cmd { return exec.Command("php", "worker.php", "pipes") },
    rr.NewPipeFactory(),
    rr.Config{
        NumWorkers:      uint64(runtime.NumCPU()),
        AllocateTimeout: time.Second,              
        DestroyTimeout:  time.Second,               
    },
)
defer p.Destroy()
rsp, err := p.Exec(&Payload{Body: []byte("hello")})
 <?php
/
 * @var Goridge\RelayInterface $relay
 */
use Spiral\Goridge;
use Spiral\RoadRunner;
$rr = new RoadRunner\Worker($relay);
while ($body = $rr->receive($context)) {
    try {
        $rr->send((string)$body, (string)$context);
    } catch (\Throwable $e) {
        $rr->error((string)$e);
    }
}
 > Check how to init relay here. More examples can be found in tests. License:The MIT License (MIT). Please see LICENSEfor more information. |