What guarantees are there for flushing the TCP send buffers, if any, when the freezer subsystem freezes a cgroup?
Consider the following scenario: Server A, which runs in a cgroup, sends data to Server B via TCP. The TCP socket is configured to use Naggle's algorithm (the TCP_NODELAY
option is not set). Therefore, send
ing data over the socket does not block for Server B's ACK but returns after the data to be sent has been copied to the TCP send buffer. After that, but before the data has been sent to Server B, the cgroup is frozen.
What happens to the data in the TCP send buffer?
- Will the freeze operation wait until all data in the buffer has been acknowledged by Server B? What if Server B's receive buffer is full? Will the freeze wait indefinitely for Server B's ack?
- Will the freeze not wait for Server B's ACK and continue to send the data after the cgroup has been thawed? If the delay between freeze and thaw is long enough for Server B to close the TCP connection, the data in the buffer will be lost.
Links to specifications and guarantees around that behavior are appreciated. But maybe there are no guarantees so relying on either behavior would be brittle?
The background of the question is that I'm wondering how careful one has to be when sending data via TCP on AWS Lambda (my assumption is that AWS Lambda uses cgroups to freeze/thaw after/before a Lambda invocation is handled). Is it enough to flush application buffers to the TCP socket/TCP send buffer? Or does one have to make sure that Server B has received the data on the application layer, for example by using HTTP and waiting for the server's HTTP response?