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

ref(server): Move body compression into EnvelopeManager (INGEST-357) #1085

Merged
merged 9 commits into from
Sep 16, 2021

Conversation

Michcioperz
Copy link
Contributor

@Michcioperz Michcioperz commented Sep 13, 2021

While researching performance of Relay I discovered that the body compression for upstream requests is run on the system arbiter instead of on a thread pool, and that removing compression increases throughput drastically.

This change moves the workload of compression from UpstreamRelay to EnvelopeProcessor, which runs on a SyncArbiter.

let (envelope_body, envelope_meta) = match Self::encode_envelope(envelope, http_encoding) {
Ok(v) => v,
Err(e) => {
return Box::new(future::err(SendEnvelopeError::SendFailed(
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'm not particularly happy about the type of this error cause it's all backwards. i was thinking of making a new variant of SendEnvelopeError (two actually, a BodyEncodingError(std::io::Error) and an EnvelopeBuildError(EnvelopeError)), but then i'd have to carry them into ProcessingError too, and i'm not 100% sure it's worth it? idk

Copy link
Member

Choose a reason for hiding this comment

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

I'd do exactly that, it's fine to have so many variants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will do

@Michcioperz Michcioperz changed the title ref(server): Move body compression into EnvelopeManager ref(server): Move body compression into EnvelopeManager (INGEST-357( Sep 13, 2021
@Michcioperz Michcioperz changed the title ref(server): Move body compression into EnvelopeManager (INGEST-357( ref(server): Move body compression into EnvelopeManager (INGEST-357) Sep 13, 2021
@Michcioperz
Copy link
Contributor Author

i ran some preliminary benchmarks and i get 1500 rps? not very cool.
i think actually envelopemanager doesn't have a syncarbiter?

Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

after the singular change to error mapping this is good to merge without another review

Comment on lines +2041 to +2045
// Override the `sent_at` timestamp. Since the envelope went through basic
// normalization, all timestamps have been corrected. We propagate the new
// `sent_at` to allow the next Relay to double-check this timestamp and
// potentially apply correction again. This is done as close to sending as
// possible so that we avoid internal delays.
Copy link
Member

Choose a reason for hiding this comment

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

Note: I think we need to live with this. This value will be horribly wrong if there is significant amount of data piling up in the queue but if we need to fix that, I question why double-checking is done at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

y'know this comment is not mine, i'm just copying it along with the rest

Copy link
Member

Choose a reason for hiding this comment

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

That's right but you were moving the code below this comment from after the upstream actor queue to before it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm tbh i think i don't quite understand what double checking we have

Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

i ran some preliminary benchmarks and i get 1500 rps? not very cool. i think actually envelopemanager doesn't have a syncarbiter?

this is actually a blocker... discussing how to solve this

@Michcioperz
Copy link
Contributor Author

benchmarking again against fake-sentry+nginx. 1000 clients over 4 locust workers. relay pinned to 6 cpu cores. just reading the rps gauge, so no flamegraph overhead.

  • before change, identity: 3500+ rps
  • before change, gzip: ~1500 rps
  • after change, identity: ~3400 rps
  • after change, gzip: ~2400 rps

so gzip is spectacularly good here imo but i'm worried about identity. thinking either a small refactor to skip encoding handling for identity or a canary to see if it matters?

@Michcioperz Michcioperz marked this pull request as ready for review September 16, 2021 09:12
@Michcioperz Michcioperz requested a review from a team September 16, 2021 09:12
Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

approving for canary

Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

let' ship

@Michcioperz Michcioperz merged commit 2e92463 into master Sep 16, 2021
@Michcioperz Michcioperz deleted the ref/sync-compression branch September 16, 2021 14:21
@github-actions
Copy link

Fails
🚫 Please consider adding a changelog entry for the next release.
Instructions and example for changelog

For changes exposed to the Python package, please add an entry to py/CHANGELOG.md. This includes, but is not limited to event normalization, PII scrubbing, and the protocol.

For changes to the Relay server, please add an entry to CHANGELOG.md under the following heading:

  1. Features: For new user-visible functionality.
  2. Bug Fixes: For user-visible bug fixes.
  3. Internal: For features and bug fixes in internal operation, especially processing mode.

To the changelog entry, please add a link to this PR (consider a more descriptive message):

- Move body compression into EnvelopeManager (INGEST-357). ([#1085](https://github.com/getsentry/relay/pull/1085))

If none of the above apply, you can opt out by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against b3e8577

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.

2 participants