shotover / shotover-proxy

L7 data-layer proxy
https://docs.shotover.io
Apache License 2.0
83 stars 16 forks source link

Port KafkaSinkSingle to use try_recv instead of recv #1610

Open rukai opened 4 months ago

rukai commented 4 months ago

prereq: https://github.com/shotover/shotover-proxy/issues/1609

This is part of https://github.com/shotover/shotover-proxy/issues/1507. Specifically the checkbox swap single sinks to use SinkConnection::try_recv instead of SinkConnection::recv

Kafka has two sink transforms: KafkaSinkSingle and KafkaSinkCluster KafkaSinkCluster has already been ported to use SinkConnection::try_recv instead of SinkConnection::recv. But we still need to port KafkaSinkSingle which is the target of this issue.

recv introduces huge delays because it does not return until the server can respond to the request which will be in the milliseconds, which is an eternity for a proxy. During this time shotover cannot process any new requests coming in from the client on this connection.

Previously we had to use the async wait in recv to avoid spin waiting. But due to recent improvements to shotover internals we can now return without waiting for all responses, so it is much more efficient to use try_recv instead.

Since we expect performance improvements from this PR, appropriate windsock benchmarks should be run to demonstrate the change actually improves performance. Take a screenshot and post it in the PR.