PHP Classes

roadrunner: Run multiple tasks of PHP in parallel using Golang

Recommend this page to a friend!
  Info   View files Example   View files View files (34)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 56 All time: 10,538 This week: 660Up
Version License PHP version Categories
roadrunner 1.0MIT/X Consortium ...5Unix, Language, Performance and optim..., P...
Description 

Author

This package can run multiple tasks of PHP in parallel using Golang.

It can start a server written in Golang communicating with it using either pipes, TCP/IP or Unix sockets.

The package can execute PHP code by sending messages to the Golang server to manage the processes of the PHP code that runs as separate workers.

Picture of Wolfy-J
Name: Wolfy-J <contact>
Classes: 4 packages by
Country: Belarus Belarus
Age: 33
All time rank: 385012 in Belarus Belarus
Week rank: 360 Up3 in Belarus Belarus Up
Innovation award
Innovation award
Nominee: 1x

Example

RoadRunner

Latest Stable Version GoDoc Build Status Go Report Card Scrutinizer Code Quality Codecov

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 LICENSE for more information.


  Files folder image Files  
File Role Description
Files folder imagesource (1 file, 1 directory)
Files folder imagetests (10 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file config.go Data Auxiliary data
Accessible without login Plain text file config_test.go Data Auxiliary data
Accessible without login Plain text file factory.go Data Auxiliary data
Accessible without login Plain text file job_error.go Data Auxiliary data
Accessible without login Plain text file job_error_test.go Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file payload.go Data Auxiliary data
Accessible without login Plain text file pipe_factory.go Data Auxiliary data
Accessible without login Plain text file pipe_factory_test.go Data Auxiliary data
Accessible without login Plain text file pool.go Data Auxiliary data
Accessible without login Plain text file pool_test.go Data Auxiliary data
Accessible without login Plain text file protocol.go Data Auxiliary data
Accessible without login Plain text file protocol_test.go Data Auxiliary data
Accessible without login Plain text file README.md Example Example script
Accessible without login Plain text file socket_factory.go Data Auxiliary data
Accessible without login Plain text file socket_factory_test.go Data Auxiliary data
Accessible without login Plain text file state.go Data Auxiliary data
Accessible without login Plain text file state_test.go Data Auxiliary data
Accessible without login Plain text file worker.go Data Auxiliary data
Accessible without login Plain text file worker_test.go Data Auxiliary data

  Files folder image Files  /  source  
File Role Description
Files folder imageExceptions (1 file)
  Plain text file Worker.php Class Class source

  Files folder image Files  /  source  /  Exceptions  
File Role Description
  Plain text file RoadRunnerException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file broken.php Example Example script
  Accessible without login Plain text file client.php Example Example script
  Accessible without login Plain text file delay.php Example Example script
  Accessible without login Plain text file echo.php Example Example script
  Accessible without login Plain text file error.php Example Example script
  Accessible without login Plain text file failboot.php Example Example script
  Accessible without login Plain text file head.php Example Example script
  Accessible without login Plain text file pid.php Example Example script
  Accessible without login Plain text file slow-client.php Example Example script
  Accessible without login Plain text file stop.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:56
This week:0
All time:10,538
This week:660Up