Introduce listener TCP connection buffer configuration and implement …#558
Introduce listener TCP connection buffer configuration and implement …#558mattklein123 merged 6 commits intoenvoyproxy:masterfrom
Conversation
…read buffer limits (envoyproxy#150). Baby steps towards flow control. This patch plumbs the TCP connection buffer limits to the listener and enforces it on the read buffer only. Later patches will also plumb to the upstream cluster connection and cover the write buffer (which requires the watermark API).
|
I'm trying to unbury myself. I will look at this later today or this weekend. |
| connection is handled by the listener that receives it. Default is false. | ||
|
|
||
| per_connection_buffer_limit_bytes | ||
| *(optional, integer)* Soft limit on size of the listener's new connection read and write buffers. If unspecified, an implementation defined default is applied. |
There was a problem hiding this comment.
Please specify the default value here.
| return read_buffer_limit_ > 0 && read_buffer_.length() >= read_buffer_limit_; | ||
| } | ||
| // Mark read buffer ready to read in the event loop. This is used when yielding following | ||
| // shouldDrainReadBuffer(). TODO(htuch): While this is the basis for also yielding to other |
There was a problem hiding this comment.
nit: put todo on new line.
mattklein123
left a comment
There was a problem hiding this comment.
Looks good. A few (annoying, sorry) comments.
| connection is handled by the listener that receives it. Default is false. | ||
|
|
||
| per_connection_buffer_limit_bytes | ||
| *(optional, integer)* Soft limit on size of the listener's new connection read and write buffers. If unspecified, an implementation defined default is applied (1MB). |
include/envoy/event/dispatcher.h
Outdated
| Network::ListenerCallbacks& cb, | ||
| Stats::Store& stats_store, bool bind_to_port, | ||
| bool use_proxy_proto, bool use_orig_dst) PURE; | ||
| bool use_proxy_proto, bool use_orig_dst, |
There was a problem hiding this comment.
Sorry, to ask you to do this, but I have a feeling we are going to keep adding params/options here. (I know soon we will split use_original_dst into use_orginal_port/use_original_address, etc.). Can we define a struct ListenerOptions and just pass that. That way we don't have to change a gazillion mocks and callsites the next time we add a param.
include/envoy/event/dispatcher.h
Outdated
| Stats::Store& stats_store, bool bind_to_port, | ||
| bool use_proxy_proto, bool use_orig_dst) PURE; | ||
| bool use_proxy_proto, bool use_orig_dst, | ||
| size_t per_connection_buffer_limit_bytes) PURE; |
There was a problem hiding this comment.
Instead of size_t, can we be specific with either uint32_t or uint64_t (probably uint32_t). Same applies all the other places we reference this.
| "use_proxy_proto" : {"type" : "boolean"}, | ||
| "use_original_dst" : {"type" : "boolean"} | ||
| "use_original_dst" : {"type" : "boolean"}, | ||
| "per_connection_buffer_limit_bytes" : { |
There was a problem hiding this comment.
"per_connection_read_buffer_limit_bytes" ? Next we will have write high/low watermark so might get confusing?
There was a problem hiding this comment.
I was planning on using per_connection_buffer_limit_bytes to drive both the watermark for the write buffer (automatically setting low watermark at a fraction like 0.5) and the read buffer, under the assumption that we want to keep config simple and that read/write buffer limits should be somewhat symmetric in general. I know there are scenarios where this isn't true, but this could be reasonable for v1.
include/envoy/network/connection.h
Outdated
| * Set a soft limit on the size of the read buffer prior to flushing to further stages in the | ||
| * processing pipeline. | ||
| */ | ||
| virtual void setReadBufferLimit(size_t limit) PURE; |
| static ListenerOptions listenerOptionsWithBindToPort() { | ||
| return {.bind_to_port_ = true, | ||
| .use_proxy_proto_ = false, | ||
| .use_original_dst_ = false, |
| Address::InstancePtr local_address_; | ||
| Buffer::OwnedImpl read_buffer_; | ||
| Buffer::OwnedImpl write_buffer_; | ||
| size_t read_buffer_limit_ = 0; |
| Ssl::Connection* ssl() override { return nullptr; } | ||
| State state() override; | ||
| void write(Buffer::Instance& data) override; | ||
| void setReadBufferLimit(size_t limit) override { read_buffer_limit_ = limit; } |
| const bool use_proxy_proto_; | ||
| ProxyProtocol proxy_protocol_; | ||
| const bool use_original_dst_; | ||
| const size_t per_connection_buffer_limit_bytes_; |
There was a problem hiding this comment.
Just have a ListenerOptions as a member var and then you can just copy it in via passed in options.
Signed-off-by: Shikugawa <Shikugawa@gmail.com>
Because we shared the `release` bazel config between both iOS and Android, Android builds were incorrectly having llvm bitcode enabled for them. Signed-off-by: Keith Smiley <keithbsmiley@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
Because we shared the `release` bazel config between both iOS and Android, Android builds were incorrectly having llvm bitcode enabled for them. Signed-off-by: Keith Smiley <keithbsmiley@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
…lang-org group across 1 directory (#558)
…read buffer limits (#150).
Baby steps towards flow control. This patch plumbs the TCP connection buffer limits to the listener
and enforces it on the read buffer only. Later patches will also plumb to the upstream cluster
connection and cover the write buffer (which requires the watermark API).