Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accesslog: Add buffering and flushing to gRPC access log #7755

Merged
merged 5 commits into from
Aug 6, 2019

Conversation

euroelessar
Copy link
Contributor

Description: Add new fields to control buffering in gRPC access log. This buffer is flushed every time when timer is elapsed, or when estimated message size grows beyond the given threshold, whichever comes first.
Risk Level: LOW
Testing: added unit tests
Docs Changes: inline in protobuf files
Release Notes: updated
Fixes #7674

Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
@euroelessar
Copy link
Contributor Author

@mattklein123 Do you think it's reasonable to enable buffering by default? I'm thinking about 64KB as a reasonable default, but a bit worried about altering the behavior of existing setups (if any).

@mattklein123 mattklein123 self-assigned this Jul 30, 2019
@mattklein123 mattklein123 added the no stalebot Disables stalebot from closing an issue label Aug 1, 2019
@mattklein123
Copy link
Member

I'm OOO for the rest of the week. I will take a look next week.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great. A few small comments.

/wait


// Soft size limit in bytes for access log entries buffer. Logger will buffer requests until
// this limit it hit, or every time flush interval is elapsed, whichever comes first. Setting it
// to zero effectively disables the batching. Defaults to 0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah IMO we should turn this on by default. WDYT about a default of 16KiB and 1s flush interval? I'm thinking that might be the least surprising and then users can tune? I'm trying to find a middle ground of responsiveness and buffering...

@@ -43,13 +43,32 @@ void GrpcAccessLoggerImpl::LocalStream::onRemoteClose(Grpc::Status::GrpcStatus,
}

GrpcAccessLoggerImpl::GrpcAccessLoggerImpl(Grpc::RawAsyncClientPtr&& client, std::string log_name,
std::chrono::milliseconds buffer_flush_interval_msec,
size_t buffer_size_bytes, Event::Dispatcher& dispatcher,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/size_t/uint64_t for buffer size (prefer explicit integer sizes in Envoy). Same elsewhere.

@@ -3,6 +3,7 @@ Version history

1.12.0 (pending)
================
* access log: added :ref:`buffering <envoy_api_field_config.accesslog.v2.CommonGrpcAccessLogConfig.buffer_size_bytes>` and :ref:`periodical flushing <envoy_api_field_config.accesslog.v2.CommonGrpcAccessLogConfig.buffer_flush_interval>` support to gRPC access logger.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to default this on, can you add the defaults to the release notes?

@mattklein123 mattklein123 removed the no stalebot Disables stalebot from closing an issue label Aug 5, 2019
Ruslan Nigmatullin added 2 commits August 5, 2019 11:36
…-log-batch

Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
cr
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7755 was synchronize by euroelessar.

see: more, trace.

Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7755 was synchronize by euroelessar.

see: more, trace.

Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7755 was synchronize by euroelessar.

see: more, trace.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@envoyproxy/api-shepherds API LGTM

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is great. One small question.

/wait-any

} else {
// Clear out the stream data due to stream creation failure.
stream_.reset();
}

// Clear the message regardless of the success.
approximate_message_size_bytes_ = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: could we potentially use the proto built-in cached size to avoid keeping track of it ourselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how. ByteSize() (or ByteSizeLong()) method does not use cached sizes for children (presumably because CachedSize is not invalidated on message modification).
Which means that the only way to use built-in cache is to manually iterate over all log entries and sum result of GetCachedSize() calls, which would be less efficient and less obvious in terms of implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK SGTM. Thanks for the explanation.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mattklein123 mattklein123 merged commit e6145e0 into envoyproxy:master Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

access log: Add ability to batch entries for grpc access log
3 participants