QA
Senior LevelPHP 8+

How does RoadRunner integrate Go (Golang) with PHP using Goroutines and IPC over Unix sockets?

❓ Interview Prompt: Explain RoadRunner application server architecture, Go process manager, Inter-Process Communication (IPC) over Unix domain sockets, and persistent workers.

RoadRunner is a high-performance open-source application server and process manager written in Go (Golang) designed specifically for PHP.

Architecture Mechanics:

1
Go Front-End: RoadRunner runs as a Go binary handling HTTP, gRPC, and WebSocket connections with Go's ultra-fast Goroutine event loops.
2
Persistent PHP Workers: RoadRunner maintains a pool of persistent PHP CLI worker processes.
3
IPC Transport: Communicates with PHP workers over fast Unix Domain Sockets or TCP using binary IPC protocols.
4
Performance Impact: Eliminates PHP-FPM boot overhead while giving PHP applications access to Go's concurrency speeds!

Code Implementation Example

php
<?php
// RoadRunner Worker Entry Point (.rr.yaml)
use Spiral\RoadRunner\Worker;
use Spiral\RoadRunner\Http\PSR7Worker;
use Nyholm\Psr7\Factory\Psr17Factory;

require __DIR__ . '/vendor/autoload.php';

$worker = Worker::create();
$psrFactory = new Psr17Factory();
$psr7 = new PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

// Loop processing incoming HTTP requests from Go parent process!
while ($req = $psr7->waitRequest()) {
    try {
        $res = new Nyholm\Psr7\Response(200, [], 'Hello from RoadRunner!');
        $psr7->respond($res);
    } catch (Throwable $e) {
        $psr7->respond(new Nyholm\Psr7\Response(500, [], 'Error'));
    }
}
💡RoadRunner worker loop receiving HTTP requests from Go parent process over IPC.
🎯 Interview Key Takeaway

RoadRunner uses Go Goroutines for network front-ends and communicates with persistent PHP CLI workers over fast Unix domain sockets.

#RoadRunner#Go#Application Server#Golang#Senior
Back to all PHP 8+ Questions→

More PHP 8+ Interview Questions

Beginner LevelPHP

What is PHP and how does its shared-nothing request lifecycle work?

Beginner LevelPHP

What is the difference between echo and print in PHP?

Beginner LevelPHP

What is the difference between isset(), empty(), and is_null() in PHP?