Reimplement multiprocess architecture#307
Draft
marksmith wants to merge 7 commits into
Draft
Conversation
Collaborator
Author
|
Tests for IPC and RPC to follow. |
7d4f9e6 to
14cdd56
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
Tests have now been added for then IPC and RPC mechanisms. Removing |
9a3493a to
9199915
Compare
9199915 to
bba0c10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Hashobjects produced by#as_jsonand consumed by#from_jsonmust haveStringkeys. 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::Serverruns in the parent process and is started at startup, andAikido::Zen::WorkerProcess::Agent::Clientruns 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:The parent processes no longer issues local requests using IPC.
Aikido::Zen::Agentoperates 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.