-
-
Notifications
You must be signed in to change notification settings - Fork 421
Closed
Labels
S-RFCRequest: Request for commentsRequest: Request for comments
Description
The file descriptor can be passed from rr process to the worker process.
The worker process will read from socket direct and write to socket direct. Possible it increases performance.
Edited:
- RR accepts the connection and receives the client socket file descriptor (FD).
- RR doesn't read data from the socket, instead, it sends FD to the
workervia the defined in the.rr.yamltransport (sockets or pipes). - In turn, the PHP worker can read and write data directly to the provided FD eliminating proxying via the RR.
ref: https://man7.org/linux/man-pages/man7/unix.7.html
FD sending:
$result = socket_sendmsg($socket, [
"iov" => [
"0", // the message
],
#"name" => [],
#"controllen" => 0,
"control" => [
[
"level" => SOL_SOCKET,
"type" => SCM_RIGHTS,
"data" => [$stream], // where $stream is socket (fd) reveived during stream_socket_accept call
],
],
], 0);FD receiving from the PHP worker POV:
$temp = [
"buffer_size" => 1, // waiting for the 1 byte of the data. In case of empty message, share the socket itself.
"controllen" => socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, 3)
];
if (socket_recvmsg($socket, $temp, MSG_DONTWAIT)) {
$message = $temp['iov'][0] ?? '';
$shareSocket = $temp['control'][0]['data'][0] ?? null; // receive the socket (fd) and operate with it directly avoiding RR proxying
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
S-RFCRequest: Request for commentsRequest: Request for comments