What is the cost of many TIME_WAIT on the server side?

后端 未结 6 433
一整个雨季
一整个雨季 2020-11-27 10:50

Let\'s assume there is a client that makes a lot of short-living connections to a server.

If the client closes the connection, there will be many ports in TIME

6条回答
  •  攒了一身酷
    2020-11-27 10:59

    Each connection is identified by a tuple (server IP, server port, client IP, client port). Crucially, the TIME_WAIT connections (whether they are on the server side or on the client side) each occupy one of these tuples.

    With the TIME_WAITs on the client side, it's easy to see why you can't make any more connections - you have no more local ports. However, the same issue applies on the server side - once it has 64k connections in TIME_WAIT state for a single client, it can't accept any more connections from that client, because it has no way to tell the difference between the old connection and the new connection - both connections are identified by the same tuple. The server should just send back RSTs to new connection attempts from that client in this case.

提交回复
热议问题