Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a RR connection manager for distributed server management #85

Open
butschster opened this issue Sep 28, 2023 · 0 comments
Open
Assignees
Labels
Component: RPC enhancement New feature or request Feature question Further information is requested
Milestone

Comments

@butschster
Copy link
Member

butschster commented Sep 28, 2023

I would like to propose a feature that facilitates a smoother integration of the RoadRunner server within a distributed environment. This would cater to scenarios where multiple instances of RoadRunner servers are being run on remote servers dedicated to different functions like cache management, job queues, and metric gathering, among others.

Image

Background

The RoadRunner server provides an RPC interface enabling communication between the server and PHP applications. This communication includes commands such as updating cache storage or sending metrics to a plugin. Here you can find more information about RPC https://roadrunner.dev/docs/php-rpc

However, when RoadRunner servers are distributed (running multiple server instances on remote servers), there arises a necessity to manage these servers' RPC connections effectively. This is to ensure that each command reaches the correct server instance based on its dedicated function.

Proposal

Introducing a class like RoaRunnerConnectionManagerInterface which would allow a convenient way to manage these connections. The interface would receive a connection name and return the proper connection with the desired RoadRunner server.

Here’s a simplified outline of what the RoaRunnerConnectionManagerInterface interface could look like:

namespace Spiral\RoadRunnerBridge;

use Spiral\Goridge\RPC\RPCInterface;

interface RoaRunnerConnectionManagerInterface
{
    public function connect(string $connection): RPCInterface;
}

Configuration

Connections can be configured in a config file, and each connection is represented by a name along with its server address.

return [
    'default' => env('RR_CONNECTION', 'app'),

    'connections' => [
        'app' => [
            'address' => 'tcp://127.0.0.1:6001',
        ],
        'cache-server' => [
            'address' => 'tcp://127.0.0.1:6004',
        ],
        'queue-server' => [
            'address' => 'tcp://127.0.0.1:6002',
        ],
        'metrics-server' => [
            'address' => 'tcp://127.0.0.1:6003',
        ],
    ],
];

Usage Example

In the context of managing a queue, connections can be set within specific bridge integrations:

use Spiral\RoadRunner\Jobs\Queue\MemoryCreateInfo;
use Spiral\RoadRunner\Jobs\Queue\AMQPCreateInfo;

return [
    // ...
    'connections' => [
        // ...
        'rr-amqp' => [
            'driver' => 'roadrunner',
           'connection' => 'queue-server',
            'pipeline' => 'low-priority',
        ],
        'rr-memory' => [
            'driver' => 'roadrunner',
            'pipeline' => 'in-memory',
        ],
    ],
];

In scenarios where no connection is specified, the default connection would be utilized.

I am looking forward to feedback and further discussions regarding the feasibility and the potential integration of this feature.

@butschster butschster self-assigned this Sep 28, 2023
@butschster butschster added enhancement New feature or request Component: RPC labels Sep 28, 2023
@butschster butschster changed the title RoadRunner bridge RPC connection manager Adding a RR connection manager for distributed server management Sep 28, 2023
@butschster butschster added question Further information is requested Feature labels Sep 28, 2023
@butschster butschster added this to the v3.x milestone Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: RPC enhancement New feature or request Feature question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant