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

perf(aws): Reduce Aggregated Kinesis Record Size #147

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

jshlbrd
Copy link
Contributor

@jshlbrd jshlbrd commented Mar 19, 2024

Description

  • Reduces the aggregated Kinesis record size from 1 MB to 25 KB
  • Replaces PutRecord call with PutRecords

Motivation and Context

Kinesis Data Streams charge based on PUT payload units, which have a minimum size of 25 KB. Historically the project aggregated up to the Kinesis limit of 1 MB because there was no support for the PutRecords API, but as of v1.0 there is. There's little (or no) value in sending aggregated records larger than 25 KB and by sending them via PutRecords the throughput performance increases by ~33% to ~50% (see screenshot).

25kb_put_records

How Has This Been Tested?

This was tested on a high-volume, production data pipeline.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jshlbrd jshlbrd marked this pull request as ready for review March 19, 2024 00:26
@jshlbrd jshlbrd requested a review from a team as a code owner March 19, 2024 00:26
kplMaxBytes = 1024 * 1024
kplMagicLen = 4 // Length of magic header for KPL Aggregate Record checking.
kplDigestSize = 16 // MD5 Message size for protobuf.
kplMaxBytes = 1000 * 25 // 25KB is the minimum size of a PUT Payload unit.
Copy link
Contributor

@shellcromancer shellcromancer Mar 19, 2024

Choose a reason for hiding this comment

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

docs: the mismatch of variable name vs comment for maximum and minimum is a bit confusing, maybe some comments could clear up how this is used or we could change the name?

Note: this is non-blocking to me, I just spent some time looking at how the variable is used and the AWS restrictions b/c of 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.

I think the comment can be improved -- the value is the maximum amount of bytes we want to allow in the aggregated (KPL) record because it is the minimum amount charged by the Kinesis service.

@jshlbrd jshlbrd merged commit a0ef232 into main Mar 19, 2024
4 checks passed
@jshlbrd jshlbrd deleted the jshlbrd/perf/kinesis-agg branch March 19, 2024 14:51
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.

None yet

2 participants