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

Add support for snappy compression in receivers #5575

Merged
merged 4 commits into from
Aug 8, 2022

Conversation

fpetkovski
Copy link
Contributor

@fpetkovski fpetkovski commented Aug 6, 2022

Distributing series between receivers is currently done by sending
uncompressed payloads which can lead to high inter-zone egress costs.

This commit adds support for using snappy compression for sending data
from one receiver to another.

Signed-off-by: Filip Petkovski [email protected]

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Fixes #5572

Changes

Add support for snappy compression in receivers.

Verification

I rolled this out in one of our environments and saw similar results as the ones reported in the Cortex PR

Bandwidth across all receivers (sum(rate(container_network_transmit_bytes_total))) went from 300MiB/s to 130MiB/s
image

CPU usage did go up by a few percent as expected
image

Results for a single receiver after rolling out snappy compression

image

image

@fpetkovski fpetkovski force-pushed the snappy-compression branch 4 times, most recently from a84c5a3 to 8417002 Compare August 6, 2022 08:59
Distributing series between receivers is currently done by sending
uncompressed payloads which can lead to high inter-zone egress costs.

This commit adds support for using snappy compression for sending data
from one receiver to another.

Signed-off-by: Filip Petkovski <[email protected]>
@fpetkovski fpetkovski changed the title Add support for snappy compression receivers Add support for snappy compression in receivers Aug 6, 2022
saswatamcode
saswatamcode previously approved these changes Aug 6, 2022
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for noticing this! 🚀

A tiny suggestion.

@@ -859,6 +868,9 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {

cmd.Flag("receive.replica-header", "HTTP header specifying the replica number of a write request.").Default(receive.DefaultReplicaHeader).StringVar(&rc.replicaHeader)

compressionOptions := strings.Join([]string{compressionNone, snappy.Name}, ", ")
cmd.Flag("receive.grpc-compression", "Compression algorithm to use for gRPC requests to other receivers. Must be one of: "+compressionOptions).Default(compressionNone).EnumVar(&rc.compression, compressionNone, snappy.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should enable it by default here? 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I agree. Enabling it by default makes more sense.

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 was going to suggest that for the v1 release, but even now it would make sense given the favourable tradeoff. Updated to default 👍

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

Not a blocker but maybe we could use s2's (https://github.com/klauspost/compress) implementation of snappy encoding/decoding from the get go? 🤔

@fpetkovski
Copy link
Contributor Author

Makes sense. How should we go about doing this? We can:

  • Update the dependency directly in the vendored Cortex file. This might get overwritten if we plan keep those files up to date.
  • Add a replace directive in go.mod
  • Reimplement the compressor inside pkg with the changed dependency.

@GiedriusS
Copy link
Member

I was thinking that (3) should be straightforward since those two libraries have identical/very similar APIs? 🤔

Signed-off-by: Filip Petkovski <[email protected]>
@fpetkovski
Copy link
Contributor Author

Got it. We should have a different implementation now with the different library.

I suspect the test failure is a flake since I can't reproduce it locally.

Signed-off-by: Filip Petkovski <[email protected]>
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

LGTM, it would be really cool to see if there's any difference in graphs @fpetkovski if you have any free time

@fpetkovski
Copy link
Contributor Author

Sure thing.

Here is the throughput with the current version:
image

The first section was when I tested the initial version, the second section (big jump) is the revert to the main branch. I now rolled out the latest commit from this branch and results are similar. I don't think there's a significant difference.

CPU usage does seem to be better with the latest commit through
image

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

I think let's move forward with the current version based on https://github.com/klauspost/compress and then if needed in the future we can always switch back

@GiedriusS GiedriusS merged commit 6670093 into thanos-io:main Aug 8, 2022
@matej-g
Copy link
Collaborator

matej-g commented Oct 5, 2022

Just additional note on this, since we were scratching our heads a bit until we figured it out - making this default markedly increased our memory consumption, it was noticeable especially on bigger instances (normally using ~35 GB memory) we've noticed that decompressing requests takes at least additional 2-3 GB per replica, so there is a trade off here. It took us a bit until we realized this is on by default in 0.28.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Receiver: reduce network bandwidth when ingesting data
5 participants