Introduce SlowOpenToxic to approximate the TCP handshake latency #536
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #123, the TCP handshake is performed by the kernel, so toxiproxy cannot inject latency there. Therefore, effects of latency on connection timeouts cannot be tested using this tool.
However, a user might be interested in the overall effects of latency from an application point of view. That is, the end-to-end effect on an entire conversation (TCP connection, application request, application response).
Using the
LatencyToxic
only, this end-to-end effect is not accurately modeled, because the initial RTT would be missing.This pull request introduces a new toxic,
SlowOpenToxic
, that simulates the handshake latency by adding a delay to the first data packet only. I hope you'll find it useful!Latencies breakdown
In reality, you would have:
Using Toxiproxy, with a
SlowOpenToxic
and aLatencyToxic
(with the same delay, equal to 1 RTT), you would have:SlowOpenToxic
and 1-RTT delay added byLatencyToxic
)LatencyToxic
).Implementation notes
LatencyToxic
. Once the first packet has been processed, a persisted State records the event and makes the toxic warm. From that point, this toxic is transparent.LatencyToxic
tests (doLatencyRound
) in order to:SlowOpenToxic
tests.LatencyToxic
andSlowOpenToxic
. To do this, I also tweaked the harness (at toxic_test.go:69) to process multiple packets, instead of stopping at the first one.