Repository navigation
lapi: make decisions stream page size configurable - #4733
Merged
Merged
Conversation
Adds api.server.decisions_stream_page_size (default 30000, the previous hardcoded value). Each in-flight /v1/decisions/stream request holds one page in memory, so lowering it caps per-request memory at the cost of more DB round trips. Refs crowdsecurity#4711
Validating in LoadAPIServer pushed it over the revive cyclomatic limit. Handle it where the value is used instead: 0 or negative falls back to 30000, and a negative value logs a warning. This also covers callers that skip LoadAPIServer, which could previously pass a negative limit.
tommy-ng0
marked this pull request as ready for review
October 4, 2026 21:44
blotus
requested changes
Oct 5, 2026
Review feedback: the key becomes decisions_stream.page_size so other stream settings can join it, and the default is set in csconfig when the config is loaded. The controller keeps a single <= 0 check that warns and falls back to the default.
blotus
approved these changes
Oct 7, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4733 +/- ##
==========================================
- Coverage 71.16% 71.16% -0.01%
==========================================
Files 538 538
Lines 36392 36405 +13
==========================================
+ Hits 25900 25909 +9
- Misses 10491 10495 +4
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 7, 2026
This was referenced Oct 16, 2026
blotus
added a commit
to crowdsecurity/crowdsec-docs
that referenced
this pull request
Oct 27, 2026
Document api.server.decisions_stream: page_size (crowdsecurity/crowdsec#4733), max_concurrent_requests and max_queue_wait (crowdsecurity/crowdsec#4747). Based on the work in #1179 and #1180. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
gabrielcosi
pushed a commit
to gabrielcosi/home-ops
that referenced
this pull request
Oct 29, 2026
… ➔ v1.8.2) (#1487) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1` → `v1.8.2` | | [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1-debian` → `v1.8.2-debian` | --- ### Release Notes <details> <summary>crowdsecurity/crowdsec (docker.io/crowdsecurity/crowdsec)</summary> ### [`v1.8.2`](https://github.com/crowdsecurity/crowdsec/releases/tag/v1.8.2) [Compare Source](crowdsecurity/crowdsec@v1.8.1...v1.8.2) ##### Version 1.8.2 - Brings [custom JS fingerprinting capabilities](https://docs.crowdsec.net/docs/next/appsec/bot_detection/custom_js/) to the bot detection feature, allowing both users and us to distribute detection rules directly via the hub. - Brings [rate limiting feature](https://docs.crowdsec.net/docs/next/appsec/rate_limiting/) to the WAF. - Brings performance improvements to the Security Engine, optimizing both memory copy behaviors and relying on static analysis to avoid processing unnecessary regular expressions. - Brings performance improvements to the WAF, optimizing out-of-band rules processing. - Brings performance improvements to the Bot Detection, optimizing memory usage. ##### New Features & Major improvements - \[WAF] Add RateLimiting feature ([#​4721](crowdsecurity/crowdsec#4721)) [@​blotus](https://github.com/blotus) - \[bot-detection] Add custom JS fingerprinting capabilities ([#​4657](crowdsecurity/crowdsec#4657)) [@​buixor](https://github.com/buixor) - \[bot-detection] Add cscli bot subcommand ([#​4666](crowdsecurity/crowdsec#4666)) [@​blotus](https://github.com/blotus) - \[WAF] Improve out-of-band rules performances ([#​4722](crowdsecurity/crowdsec#4722)) [@​blotus](https://github.com/blotus) - \[Security Engine] Run postoverflows in a separate goroutine to avoid blocking on slow enrichments ([#​4672](crowdsecurity/crowdsec#4672)) [@​blotus](https://github.com/blotus) - \[bot-detection] Improve memory usage ([#​4674](crowdsecurity/crowdsec#4674)) [@​blotus](https://github.com/blotus) - \[Security Engine] Various performance improvements to regular expression processing ([#​4736](crowdsecurity/crowdsec#4736)) ([#​4731](crowdsecurity/crowdsec#4731)) ([#​4729](crowdsecurity/crowdsec#4729)) [@​blotus](https://github.com/blotus) [@​buixor](https://github.com/buixor) ##### Improvements - Add `cs_features` metric ([#​4770](crowdsecurity/crowdsec#4770)) [@​blotus](https://github.com/blotus) - bot detection: add an option to set SameSite=None + Partitioned flag on cookie ([#​4764](crowdsecurity/crowdsec#4764)) [@​blotus](https://github.com/blotus) - exprhelpers: add GetDecisionsSinceCountByScenario ([#​4756](crowdsecurity/crowdsec#4756)) [@​tommy-ng0](https://github.com/tommy-ng0) - lapi: optionally limit concurrent decision stream requests ([#​4747](crowdsecurity/crowdsec#4747)) [@​tommy-ng0](https://github.com/tommy-ng0) - exprhelpers: LookupHost goes through the DNS cache ([#​4741](crowdsecurity/crowdsec#4741)) [@​twiesing](https://github.com/twiesing) - metrics: add CAPI last pull timestamp and error counter ([#​4749](crowdsecurity/crowdsec#4749)) [@​NazarkinRoman](https://github.com/NazarkinRoman) - prometheus: add kind label to cs_alerts ([#​4742](crowdsecurity/crowdsec#4742)) [@​blotus](https://github.com/blotus) - lapi: make decisions stream page size configurable ([#​4733](crowdsecurity/crowdsec#4733)) [@​tommy-ng0](https://github.com/tommy-ng0) - Fix ValidateChallengeResponse ([#​4737](crowdsecurity/crowdsec#4737)) [@​buixor](https://github.com/buixor) - bot-detection: add new FlagSubmission() helper ([#​4727](crowdsecurity/crowdsec#4727)) [@​blotus](https://github.com/blotus) - appsec: add an optional category to the request score ([#​4715](crowdsecurity/crowdsec#4715)) [@​buixor](https://github.com/buixor) - apiserver: reload the TLS server certificate when its files change ([#​4709](crowdsecurity/crowdsec#4709)) [@​ohartwig](https://github.com/ohartwig) - fix image link ([#​4702](crowdsecurity/crowdsec#4702)) [@​buixor](https://github.com/buixor) - waf: add SkipProcessing() helper ([#​4667](crowdsecurity/crowdsec#4667)) [@​blotus](https://github.com/blotus) - \[bot-detection] drop the URI from the cookie ([#​4656](crowdsecurity/crowdsec#4656)) [@​buixor](https://github.com/buixor) ##### Bug Fixes - acquisition/file: don't send half-written lines, or skip the lines after them ([#​4678](crowdsecurity/crowdsec#4678)) [@​n1koo](https://github.com/n1koo), [@​blotus](https://github.com/blotus), [@​claude](https://github.com/claude) - fix(cscli): display human-readable timestamps in local time ([#​4759](crowdsecurity/crowdsec#4759)) [@​sep2](https://github.com/sep2) - remove runtime Fatalf calls ([#​4760](crowdsecurity/crowdsec#4760)) [@​blotus](https://github.com/blotus) - waf: fix log spam when usin unix socket on freebsd ([#​4745](crowdsecurity/crowdsec#4745)) [@​blotus](https://github.com/blotus) - docker: read from now if container restarts ([#​4605](crowdsecurity/crowdsec#4605)) [@​blotus](https://github.com/blotus) - splunk-notification: add an option to configure InsecureSkipVerify ([#​4720](crowdsecurity/crowdsec#4720)) [@​blotus](https://github.com/blotus) - victorialogs: move the datasource to RestartableStreamer interface ([#​4738](crowdsecurity/crowdsec#4738)) [@​blotus](https://github.com/blotus) - metrics: remove series of deleted machines and bouncers ([#​4712](crowdsecurity/crowdsec#4712)) [@​somaz94](https://github.com/somaz94) - buckets: make a copy of all event maps before pouring the event to a bucket ([#​4481](crowdsecurity/crowdsec#4481)) [@​blotus](https://github.com/blotus) - fix(database): keep simulated decisions from suppressing real bans ([#​4679](crowdsecurity/crowdsec#4679)) [@​4erdenko](https://github.com/4erdenko), [@​blotus](https://github.com/blotus) - fix a nasty bug in transfrom where the effective uuid for a datasource ([#​4697](crowdsecurity/crowdsec#4697)) [@​sabban](https://github.com/sabban) - hubtest: add a tiebreaker based on the alert date to have a consistent order ([#​4699](crowdsecurity/crowdsec#4699)) [@​blotus](https://github.com/blotus) - syslog: copy buffer before handing it to the datasource ([#​4690](crowdsecurity/crowdsec#4690)) [@​blotus](https://github.com/blotus) - Expand env vars in online_api_credentials.yaml ([#​4677](crowdsecurity/crowdsec#4677)) [@​kushiemoon-dev](https://github.com/kushiemoon-dev) ##### Chore / Deps - build(deps): bump the gomod group with 5 updates ([#​4778](crowdsecurity/crowdsec#4778)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the github-actions group with 2 updates ([#​4777](crowdsecurity/crowdsec#4777)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump certifi from 2026.1.4 to 2026.10.19 in /build/docker/test ([#​4780](crowdsecurity/crowdsec#4780)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the github-actions group across 1 directory with 8 updates ([#​4766](crowdsecurity/crowdsec#4766)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 16 updates ([#​4767](crowdsecurity/crowdsec#4767)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 8 updates ([#​4753](crowdsecurity/crowdsec#4753)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - fpscanner: use fork ([#​4761](crowdsecurity/crowdsec#4761)) [@​blotus](https://github.com/blotus) - waf: update to coraza 3.8.0 ([#​4724](crowdsecurity/crowdsec#4724)) [@​blotus](https://github.com/blotus), [@​buixor](https://github.com/buixor) - build(deps): bump the gomod group across 1 directory with 19 updates ([#​4730](crowdsecurity/crowdsec#4730)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - CI: skip more docker tests on windows ([#​4728](crowdsecurity/crowdsec#4728)) [@​blotus](https://github.com/blotus) - grok: embed grok library instead of having it as a dep ([#​4725](crowdsecurity/crowdsec#4725)) [@​blotus](https://github.com/blotus) - docker datasource: skip tests on windows ([#​4719](crowdsecurity/crowdsec#4719)) [@​blotus](https://github.com/blotus) - agents.md: keep comments to a reasonable level ([#​4716](crowdsecurity/crowdsec#4716)) [@​blotus](https://github.com/blotus) - build(deps): bump the github-actions group with 7 updates ([#​4693](crowdsecurity/crowdsec#4693)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 11 updates ([#​4694](crowdsecurity/crowdsec#4694)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump github.com/go-openapi/validate from 0.26.5 to 1.0.0 ([#​4682](crowdsecurity/crowdsec#4682)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 19 updates ([#​4681](crowdsecurity/crowdsec#4681)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump cryptography from 48.0.1 to 50.0.0 in /build/docker/test ([#​4591](crowdsecurity/crowdsec#4591)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - bump to go 1.27 ([#​4675](crowdsecurity/crowdsec#4675)) [@​blotus](https://github.com/blotus) - build(deps): bump the github-actions group across 1 directory with 3 updates ([#​4658](crowdsecurity/crowdsec#4658)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group across 1 directory with 21 updates ([#​4659](crowdsecurity/crowdsec#4659)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - AGENTS.md: clearer guidance on tests ([#​4713](crowdsecurity/crowdsec#4713)) [@​blotus](https://github.com/blotus) - pimp readme ([#​4701](crowdsecurity/crowdsec#4701)) [@​buixor](https://github.com/buixor) ##### Geolite2 notice This product includes GeoLite2 data created by MaxMind, available from <a href="https://www.maxmind.com"><https://www.maxmind.com></a>. ##### Installation Take a look at the [installation instructions](https://doc.crowdsec.net/docs/getting_started/install_crowdsec). </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/Berlin) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.xcd.dev/gabrielcosi/home-ops/pulls/1487
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new config key:
api.server.decisions_stream.page_size.What and why
Each in-flight
/v1/decisions/streamrequest holds one page of decisions in memory, and the page size was hardcoded to 30000 (// FIXME : make it configurable). With ~1.2k bouncers pulling a large delta at once, that's what put our LAPI into an OOM loop.This makes the page size configurable, as suggested in #4711:
It lives in its own
decisions_streamsection so other stream settings (like a concurrent requests limit) can join it. csconfig sets the default (30000) when the section orpage_sizeis unset. The controller falls back to the default with a warning for a value of 0 or less, because ent dropsLIMITfor 0 and SQLite ignores a negative one, so a non-positive value must never reach the query.Lower values cap memory per request, at the cost of more DB round trips (the dedup subquery runs once per page). Bouncers see no difference: a pull is still one response with every decision in it.
Part of #4711
How it was tested
TestStreamDecisionPageSizeruns the stream with page sizes of 1, 2 and 5 against 5 active and 3 expired decisions, so the startup resync and the delta both crossid_gtpage boundaries. It also checks that an unset section, 0 and -1 fall back to 30000.TestLoadDecisionsStreamcovers the csconfig default.To check the tests aren't tautological, I broke the paging loop end condition, the config wiring, the non-positive fallback, and the csconfig default, one at a time. A test failed each time.
golangci-lint 2.13.2, run like
make lintfor linux, windows and freebsd: no issues in the changed files. All three report the same 22 issues thatmasterreports with this version.Not yet done: a local run against a real instance.
Checklist
cscli -o json|rawoutput.AI assistance used: mostly
/kind enhancement
/area local-api
/area configuration