开发者

State of preexisting connections when using file descriptor passing?

开发者 https://www.devze.com 2023-01-12 06:54 出处:网络
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

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 开发者_C百科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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消