Repository navigation
Http concurrency limiter - #35820
Http concurrency limiter#35820Clamenda wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugin/http.go" line_range="97" />
<code_context>
return nil, err
}
p.pipeline = pipe
+ p.ctx = ctx
+
+ limiter, err := cc.Concurrency.limiter()
</code_context>
<issue_to_address>
**Configured requests stop after setup**
When an HTTP plugin with concurrency enabled is created using a context that is canceled when its configuration request completes, `NewHTTPPluginFromConfig` retains the factory context in `p.ctx`, and `request` uses it for every limiter acquisition. Plugins created from the configuration API’s request context therefore fail with cancellation after the setup request ends, so their subsequent HTTP requests never reach the server.
Use a plugin-lifetime context for limiter waits, or pass a per-request context that remains valid for the plugin’s requests.
</issue_to_address>
### Comment 2
<location path="plugin/http_limit.go" line_range="60" />
<code_context>
+ group: group,
+ limit: limit,
+ }
+ httpConcurrencyGroups[group] = limiter
+ return limiter, nil
+}
</code_context>
<issue_to_address>
**Changed limits require restart**
When a plugin is reconfigured or removed and a later configuration reuses its group with a different limit, `httpConcurrencyGroups` retains the limiter after its plugin instances are removed, so constructing a replacement with the same group and a new limit returns a conflict and the reconfiguration fails.
Manage group registrations across reconfiguration, or provide a supported way to change a group's limit without restarting the process.
</issue_to_address>
### Comment 3
<location path="templates/definition/tariff/open-meteo-temperature.yaml" line_range="53-55" />
<code_context>
+```yaml
+source: http
+uri: https://example.org/forecast
+concurrency:
+ group: weather-provider
+ limit: 3
</code_context>
<issue_to_address>
**Open-Meteo docs omit concurrency configuration**
When either Open-Meteo tariff template gains the concurrency block, the generated template documentation stays out of sync with these tariff templates, so users consulting it do not see the new concurrency settings.
Run `make docs` and include the generated template documentation changes.
Also at `templates/definition/tariff/open-meteo.yaml:95-97`.
</issue_to_address>|
HTTP 429 is not related to concurrency. |
|
That's what I also thought first, until I saw the response: reason:"Too many concurrent requests" |
|
@Clamenda pls always mention the issue your PR fixes |
|
Thanks for the PR and the trace log. The trace shows Open-Meteo answers @Clamenda could you test #35898 with your seven Open-Meteo forecasts? A test build will be attached to that PR shortly. Please report whether all tariffs start without the 429 error. 🤖 Generated with Claude Code |
|
And much simpler, no config required. |
Fix #35752
As stated in issue #35752, this solves the problem when a HTTP server allows only a certain number of concurrent requests. In the case of Open-Meteo, only 5 concurrent requests are allowed.
It adds an optional, generic concurrency configuration to the HTTP plugin containing a group and a limit. All HTTP plugin instances with the same group share the same semaphore with the configured limit over which the concurrency-limitation is handled. If no concurrency configuration is specified, the behavior is unchanged.
At the moment this concurrency limiter is only applied to the two Open-Meteo tariff templates.