Skip to content

feat(gateway): throttling support for internal batch endpoint - #7055

Merged
atzoum merged 2 commits into
masterfrom
feat.ibthrottling
Jun 11, 2026
Merged

atzoum merged 2 commits into
masterfrom
feat.ibthrottling

Conversation

@atzoum

@atzoum atzoum commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adding support for throttling the internal batch endpoint, using an in-memory throttler. Both event rate and event window is configurable and throttler can be disabled by setting the window to zero.
Throttler expects the presence of X-Batch-Size request header. If it is not present it will skip throttling and increment the gateway_internal_batch_throttle_skip counter with a reason: no_header label.

Linear Ticket

resolves PIPE-3102

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@atzoum
atzoum force-pushed the feat.ibthrottling branch 3 times, most recently from 449dfd9 to 9118c6d Compare June 5, 2026 13:51
@codecov

codecov Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.78%. Comparing base (dc071cd) to head (6279a62).

Files with missing lines Patch % Lines
gateway/handle.go 83.33% 2 Missing and 1 partial ⚠️
gateway/handle_lifecycle.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7055      +/-   ##
==========================================
+ Coverage   79.37%   79.78%   +0.41%     
==========================================
  Files         581      581              
  Lines       64644    64671      +27     
==========================================
+ Hits        51311    51598     +287     
+ Misses      10274     9985     -289     
- Partials     3059     3088      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@atzoum
atzoum force-pushed the feat.ibthrottling branch 5 times, most recently from b42f948 to 1acd753 Compare June 9, 2026 06:14
@ktgowtham
ktgowtham removed request for itsmihir and mihir20 June 9, 2026 11:07
@atzoum
atzoum force-pushed the feat.ibthrottling branch 2 times, most recently from a8cfa5e to e1ac7d0 Compare June 9, 2026 14:32
Comment thread gateway/handle.go
func (gw *Handle) internalBatchAllow(ctx context.Context, n int) bool {
limit := gw.conf.internalBatchThrottleEvents.Load()
if limit <= 0 {
gw.internalBatchThrottleSkipDisabledCounter.Increment()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

3 counters for such a small feature seem a bit overkill. Do we really need to increase a counter everytime we get a request just because we disabled throttling by setting the limit to 0? Wouldn't it make more sense to have a metric for throttle denials?

@atzoum atzoum Jun 10, 2026 •

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.

3 counters still cost less than 1 histogram :)

Wouldn't it make more sense to have a metric for throttle denials?

Please elaborate on throttle denials

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For throttle denials I was suggesting a counter though 😅

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.

Have a counter to count how many times we return a 429? We have http stats for that purpose

Comment thread gateway/handle_test.go Resolved
@atzoum
atzoum force-pushed the feat.ibthrottling branch from e1ac7d0 to fdbf84e Compare June 10, 2026 13:40
🔒 Scanned for secrets using gitleaks 8.30.1
@atzoum
atzoum requested a review from fracasula June 10, 2026 16:18
Comment thread gateway/handle.go
} else if batchSize, parseErr := strconv.Atoi(batchSizeStr); parseErr != nil || batchSize <= 0 {
gw.internalBatchThrottleSkipInvalidHeaderCounter.Increment()
} else if !gw.internalBatchAllow(ctx, batchSize) {
http.Error(w, response.GetStatus(response.TooManyRequests), http.StatusTooManyRequests)

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.

response.TooManyRequests

NIT: should we return back max events limit reached

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.

Since this throttler only applies to the internal batch endpoint and no human or machine will ever going to read the response body, I will defer adding this additional entry into the status map :)

@atzoum
atzoum merged commit 6b6ba65 into master Jun 11, 2026
106 of 110 checks passed
@atzoum
atzoum deleted the feat.ibthrottling branch June 11, 2026 12:38
atzoum pushed a commit that referenced this pull request Jun 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.78.0-rc.1](v1.77.0...v1.78.0-rc.1)
(2026-06-22)


### Features

* add and register bq stream v2 async destination manager
([#7057](#7057))
([787b7ac](787b7ac))
* add BQSTREAM_V2 destination type and bqstreamv2 building blocks
([#7056](#7056))
([02e84e5](02e84e5))
* **batchrouter:** raise getImportingJobs max iterations and remove
payload size limit
([#7076](#7076))
([15707f6](15707f6))
* **gateway:** throttling support for internal batch endpoint
([#7055](#7055))
([6b6ba65](6b6ba65))
* **jobsdb:** introduce compaction min ds age
([#7077](#7077))
([4d6d97a](4d6d97a))
* **processor:** new intermediate jobsdb
([#7048](#7048))
([dfef1f1](dfef1f1))


### Bug Fixes

* abort non-retryable Klaviyo upload errors instead of retrying
([#7085](#7085))
([4c3e4f1](4c3e4f1))
* **batchrouter:** correlate poll results by externalId instead of
whole-row hash
([09326d2](09326d2))
* **batchrouter:** report real status code and sample event for drained
jobs ([#7104](#7104))
([d3fab82](d3fab82))
* internal endpoints enabled in open source version of rudder-server
([#7075](#7075))
([dc071cd](dc071cd))
* **jobsdb:** get jobs lateral join against the v_last view
([#7105](#7105))
([853d14c](853d14c))
* klaviyo upload partial failures
([#7107](#7107))
([37e79e9](37e79e9))
* **router:** shared barrier causing illegal job sequence errors
([#7101](#7101))
([b5435ba](b5435ba))


### Miscellaneous

* add BQSTREAM_V2 integration tests
([#7058](#7058))
([478e217](478e217))
* add rudderai announcement
([#7046](#7046))
([ff02fe8](ff02fe8))
* bump codecov-action to 7.0.0
([#7070](#7070))
([31f0623](31f0623))
* cleanup embedded warehouse transformations
([#7072](#7072))
([31f0623](31f0623))
* **deps:** bump actions/checkout from 6.0.2 to 6.0.3
([#7084](#7084))
([745d5ab](745d5ab))
* **deps:** bump aws-actions/configure-aws-credentials from 6.1.2 to
6.2.0 ([#7081](#7081))
([19251cd](19251cd))
* **jobsdb:** refactoring and cleanup
([#7043](#7043))
([2e4ea92](2e4ea92))
* remove legacy warehouse endpoints
([#7090](#7090))
([6f85153](6f85153))
* rename bqstream all events
([#7088](#7088))
([4d9ad19](4d9ad19))
* **router:** rename experimental buffer size calculator to dynamic
([#7103](#7103))
([52896cd](52896cd))
* support using the full event schema key as pulsar ordering key
([#7086](#7086))
([ff50611](ff50611))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
atzoum pushed a commit that referenced this pull request Jun 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.78.0](v1.77.0...v1.78.0)
(2026-06-22)


### Features

* add and register bq stream v2 async destination manager
([#7057](#7057))
([787b7ac](787b7ac))
* add BQSTREAM_V2 destination type and bqstreamv2 building blocks
([#7056](#7056))
([02e84e5](02e84e5))
* **batchrouter:** raise getImportingJobs max iterations and remove
payload size limit
([#7076](#7076))
([15707f6](15707f6))
* **gateway:** throttling support for internal batch endpoint
([#7055](#7055))
([6b6ba65](6b6ba65))
* **jobsdb:** introduce compaction min ds age
([#7077](#7077))
([4d6d97a](4d6d97a))
* **processor:** new intermediate jobsdb
([#7048](#7048))
([dfef1f1](dfef1f1))


### Bug Fixes

* abort non-retryable Klaviyo upload errors instead of retrying
([#7085](#7085))
([4c3e4f1](4c3e4f1))
* **batchrouter:** correlate poll results by externalId instead of
whole-row hash
([09326d2](09326d2))
* **batchrouter:** report real status code and sample event for drained
jobs ([#7104](#7104))
([d3fab82](d3fab82))
* internal endpoints enabled in open source version of rudder-server
([#7075](#7075))
([dc071cd](dc071cd))
* **jobsdb:** get jobs lateral join against the v_last view
([#7105](#7105))
([853d14c](853d14c))
* klaviyo upload partial failures
([#7107](#7107))
([37e79e9](37e79e9))
* **router:** shared barrier causing illegal job sequence errors
([#7101](#7101))
([b5435ba](b5435ba))


### Miscellaneous

* add BQSTREAM_V2 integration tests
([#7058](#7058))
([478e217](478e217))
* add rudderai announcement
([#7046](#7046))
([ff02fe8](ff02fe8))
* bump codecov-action to 7.0.0
([#7070](#7070))
([31f0623](31f0623))
* cleanup embedded warehouse transformations
([#7072](#7072))
([31f0623](31f0623))
* **deps:** bump actions/checkout from 6.0.2 to 6.0.3
([#7084](#7084))
([745d5ab](745d5ab))
* **deps:** bump aws-actions/configure-aws-credentials from 6.1.2 to
6.2.0 ([#7081](#7081))
([19251cd](19251cd))
* **jobsdb:** refactoring and cleanup
([#7043](#7043))
([2e4ea92](2e4ea92))
* remove legacy warehouse endpoints
([#7090](#7090))
([6f85153](6f85153))
* rename bqstream all events
([#7088](#7088))
([4d9ad19](4d9ad19))
* **router:** rename experimental buffer size calculator to dynamic
([#7103](#7103))
([52896cd](52896cd))
* support using the full event schema key as pulsar ordering key
([#7086](#7086))
([ff50611](ff50611))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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.

3 participants