使用文件描述符传递时现有连接的状态?

发布于 2024-09-15 04:52:40 字数 317 浏览 7 评论 0原文

我正在使用一个网络服务器,使用unix套接字和sendmsg/recvmsg将套接字文件描述符传递给新的服务器进程,而不会丢失任何请求。在使用 ab 进行测试时,我发现客户端连接会持续存在,并且 apachebench (ab) 将显示错误:“apr_poll:指定的超时已过期 (70007)”。

我怀疑文件描述符的地址发生了变化,这会使打开的连接变得无用,但是确保在每个请求结束时关闭连接并没有什么区别,有几个请求会失败。

套接字级别是否有一些额外的奇怪现象,或者 ab 只是很奇怪?还有什么我应该考虑的吗?

编辑:使用 PHP 作为客户端发出请求也会在周期期间停止。

I'm playing around with a webserver, using a unix socket and sendmsg / recvmsg to pass the socket file descriptor to a new server process without losing any requests. While testing it with ab I found that client connections would linger, and apachebench (ab) would show the error: "apr_poll: The timeout specified has expired (70007)".

I suspected that there was a change to the address of the file descriptor that would render open connections useless, however making sure the connections were closed at the end of every request didn't make a difference, a couple of the requests would fail.

Is there some extra oddity at the socket level or is ab just being weird? Is there anything else I should take into account?

Edit: Using PHP as a client to make requests also stalls during the cycle.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月蹉跎了容颜 2024-09-22 04:52:40

如果您有一个正在侦听套接字(接受传入连接)的主服务器并且您有多个工作进程,那么它确实有意义。

您可以选择一个合适的/空闲的worker(例如,基于每个worker正在使用的TCP连接数)并将传入连接的描述符从master传递到worker。当多个工作人员在公共端点上侦听时,这有助于避免“惊群”。

It does make sense if you have a master server which is listening on a socket (accepting incoming connections) and you have multiple worker processes.

You can select a suitable/free worker (for example, based on the number of TCP connections every worker is using) and pass the descriptor of the incoming connection from the master to the worker. This helps to avoid the "thundering herd" when multiple workers listen on the common endpoint.

陌伤浅笑 2024-09-22 04:52:40

这相当于尝试通过电话线发送电话。这没有任何意义。套接字 fd 标识连接的端点。如果另一个主机想要连接,它必须建立自己的连接。你不能给它你的之一。

That's equivalent to trying to send a telephone over a telephone line. It doesn't make any sense. A socket fd identifies the endpoint of a connection. If another host wants a connection it will have to mke its own. You can't give it one of yours.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文