Skip to content

Size-based packetization for dogstatsd batched metrics #562

Merged
prognant merged 3 commits intomasterfrom
prognant/packet-size
Jun 11, 2020
Merged

Size-based packetization for dogstatsd batched metrics #562
prognant merged 3 commits intomasterfrom
prognant/packet-size

Conversation

@prognant
Copy link
Copy Markdown
Contributor

@prognant prognant commented May 7, 2020

What does this PR do?

It improves the packetization while sending batched metrics with packet size adjusted to prevent fragmentation while maximizing payload usage. Telemetry is sent in separate packets, once every 10 seconds won't impact overall performance. API is backward compatible, max_buffer_size has been deprecated but not removed, warning are logged if the parameter is used when building Dogstatsd objects.

Description of the Change

It adds sending heuristic based on current buffer length. Some approximation regarding the actual bytes sent on wire include unicode character encoding (note that the telemetry is not accounting for that either).

Alternate Designs

Better optimal packet size detection could have been considered but it seems overkill, moreover the settings can be overridden.

Possible Drawbacks

Verification Process

Unit tests, integration tests, manual tests, packet capture.

Additional Notes

Future rework of the client is planned and will include better multithreading awareness and optimal packet size management without the need to use batched metrics pattern.

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@prognant prognant requested a review from a team as a code owner May 7, 2020 10:03
@prognant prognant added the changelog/Changed Changed features results into a major version bump label May 7, 2020
Copy link
Copy Markdown
Member

@hush-hush hush-hush 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 we should deprecate the old behavior. If a user set a number of metrics per buffer we respect and don't check for size.
By default max_buffer_size would be zero and we would use the actual byte size.

@prognant prognant force-pushed the prognant/packet-size branch from 2bf0d57 to 62274cb Compare May 28, 2020 13:57
@prognant prognant requested a review from hush-hush May 29, 2020 09:24
@prognant prognant force-pushed the prognant/packet-size branch from 62274cb to 35732b3 Compare May 29, 2020 09:27
Copy link
Copy Markdown
Member

@hush-hush hush-hush left a comment

Choose a reason for hiding this comment

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

Overall it looks good. Since the API for DogStatsd changed we should bump the major, but I'm not sure if we can do it since the whole repo contains multiple project. We should sync with ing-tool-libs on this.

If bumping the major is not possible, we could still receive max_buffer_size in the API but not use it and print a warning ?

@prognant
Copy link
Copy Markdown
Contributor Author

prognant commented Jun 8, 2020

Overall it looks good. Since the API for DogStatsd changed we should bump the major, but I'm not sure if we can do it since the whole repo contains multiple project. We should sync with ing-tool-libs on this.

If bumping the major is not possible, we could still receive max_buffer_size in the API but not use it and print a warning ?

I will sync & assess the situation with ing-tool-libs

return self.socket

def open_buffer(self, max_buffer_size=50):
def open_buffer(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This breaks the current API FWIW.
I'm not against it, but if you're going to break the API, it'd be better to provide a new one that e.g. fixes #439

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had a quick discussion about that, we agreed not to break the API, pending upcoming rework (I keep in mind the redis pipeline idea thanks again BTW).

@prognant prognant force-pushed the prognant/packet-size branch 2 times, most recently from 77c9b25 to 00368b5 Compare June 8, 2020 13:40
hush-hush
hush-hush previously approved these changes Jun 8, 2020
@prognant prognant force-pushed the prognant/packet-size branch from e8a0e04 to 46a5570 Compare June 11, 2020 09:22
@prognant prognant merged commit 19dd434 into master Jun 11, 2020
@prognant prognant deleted the prognant/packet-size branch June 11, 2020 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Changed Changed features results into a major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants