Skip to content

Reimplement multiprocess architecture#307

Draft
marksmith wants to merge 7 commits into
mainfrom
reimplement-multiprocess-architecture
Draft

Reimplement multiprocess architecture#307
marksmith wants to merge 7 commits into
mainfrom
reimplement-multiprocess-architecture

Conversation

@marksmith

Copy link
Copy Markdown
Collaborator

This change resolves several long-standing concerns with DRb, by replacing DRb for inter-process communication with an appropriate IPC and RPC mechanism; enabling the significant cleanup and simplification of the multiprocessor architecture.

The change begins by correcting another long-standing concern. Hash objects produced by #as_json and consumed by #from_json must have String keys. This is addressed first order to remove sources of errors, since the RPC mechanism uses JSON encoding.

The IPC mechanism uses an ephemeral port and an in-memory cryptographically secure random secret that are inherited by child processes at fork and used to restrict connection to real child processes using a mutual challenge-response protocol (built on HMAC-SHA256 and constant time comparison from OpenSSL).

The RPC mechanism is built on top of the IPC mechanism and is similar conceptually JSONRPC-2.0.

The multiprocessor architecture now consists of two parts.Aikido::Zen::WorkerProcess::Agent::Server runs in the parent process and is started at startup, and Aikido::Zen::WorkerProcess::Agent::Client runs in the child process and is started when a child process detected and handles the processes forking (on the first request after forking). The client in the child process makes requests of the server in the parent process. Two kinds of request are supported:

  • synchronous requests, issued using invoke, which return a result
  • asynchronous requests, issued using notify, which do not return a result

The parent processes no longer issues local requests using IPC. Aikido::Zen::Agent operates independently of the worker process server running in same processes or worker processes clients running in the child processes.

When the agent requests data from the API it caches the results. When the worker process requests data from the parent process no serialization is performed. The server returns the already-serialized cached data from the API and the child process handles it using the same logic as the parent processes.

@marksmith

Copy link
Copy Markdown
Collaborator Author

Tests for IPC and RPC to follow.

@marksmith marksmith force-pushed the reimplement-multiprocess-architecture branch from 7d4f9e6 to 14cdd56 Compare June 23, 2026 15:56
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

@marksmith

Copy link
Copy Markdown
Collaborator Author

#notify has been removed, since it was only used in one place and that use case could be effectively replaced by responding early (before the handler has completed processing).

Tests have now been added for then IPC and RPC mechanisms. Removing #notify significantly reduced the number of tests that were required.

@marksmith marksmith force-pushed the reimplement-multiprocess-architecture branch 3 times, most recently from 9a3493a to 9199915 Compare June 26, 2026 15:18
@marksmith marksmith force-pushed the reimplement-multiprocess-architecture branch from 9199915 to bba0c10 Compare June 30, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant