在应用程序之间共享套接字有什么好处?

时间:2022-08-26 19:02:00

Looking at Circus, a Python app for managing sockets and processes, I'm left wondering what the technical advantage is with sharing/reusing sockets between applications instead of allowing each application their own private socket. Can someone explain this?

看看Circus,一个用于管理套接字和进程的Python应用程序,我想知道在应用程序之间共享/重用套接字而不是允许每个应用程序都有自己的私有套接字的技术优势是什么。有人可以解释一下吗?

Circus's docs can be found here: http://circus.readthedocs.org/en/0.6/sockets/#sockets

马戏团的文档可以在这里找到:http://circus.readthedocs.org/en/0.6/sockets/#sockets

1 个解决方案

#1


1  

If each child process listens on its own socket, then a parent process will have to handle all connections before distributing them between child process. This is not scalable, since the parent process have too much work.

如果每个子进程都在自己的套接字上进行侦听,那么父进程必须在子进程之间分配它们之前处理所有连接。这不可扩展,因为父进程有太多工作。

When multiple child processes share a socket with the parent process ( this is done by forking child processes from the parent process), each child process can accept connection independently, the distribution is handled by the OS kernel, which does it very efficiently.

当多个子进程与父进程共享套接字时(这是通过从父进程分配子进程完成的),每个子进程可以独立地接受连接,分发由OS内核处理,这非常有效。

#1


1  

If each child process listens on its own socket, then a parent process will have to handle all connections before distributing them between child process. This is not scalable, since the parent process have too much work.

如果每个子进程都在自己的套接字上进行侦听,那么父进程必须在子进程之间分配它们之前处理所有连接。这不可扩展,因为父进程有太多工作。

When multiple child processes share a socket with the parent process ( this is done by forking child processes from the parent process), each child process can accept connection independently, the distribution is handled by the OS kernel, which does it very efficiently.

当多个子进程与父进程共享套接字时(这是通过从父进程分配子进程完成的),每个子进程可以独立地接受连接,分发由OS内核处理,这非常有效。