summaryrefslogtreecommitdiff
path: root/README.md
blob: e70a6be1c4fe7203bf2c6a87da9fc4fb5a1dceb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
RoadRunner
==========
[![GoDoc](https://godoc.org/github.com/spiral/roadrunner?status.svg)](https://godoc.org/github.com/spiral/roadrunner)
[![Build Status](https://travis-ci.org/spiral/roadrunner.svg?branch=master)](https://travis-ci.org/spiral/roadrunner)

High-performance PHP job balancer for Golang.

Features:
--------
- load balancer, process manager and task pipeline 
- swaps workers without stopping the server
- build for multiple frontends (queue, rest, psr-7, async php, etc)
- works over TPC, unix sockets and standard pipes
- automatic worker replacement
- safe worker destruction
- worker lifecycle management (create/stop/allocate timeouts)
- payload context
- protocol, job and worker level error management
- very fast (~250k calls per second on Ryzen 1700X over 16 threads)
- works on Windows

Examples:
--------

```go
p, err := NewPool(
    func() *exec.Cmd { return exec.Command("php", "worker.php") },
    NewPipeFactory(),
    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 ($in = $rr->receive($ctx)) {
    try {
        $rr->send((string)$in);
    } catch (\Throwable $e) {
        $rr->error((string)$e);
    }
}
```

License:
--------
The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.