Skip to content

Pace large blocklist pulls: insert in configurable chunks instead of one burst #4711

Closed

Description

@tommy-ng0

/kind enhancement

What would you like to be added?

When a blocklist pull brings in a large list, insert it in chunks spread over time instead of one SaveAlerts call, with both the chunk size and the gap between chunks configurable:

api:
  server:
    online_client:
      pull:
        blocklists: true
        chunk_size: 10000
        chunk_interval: 60s

A 72,863-entry list would then land as 8 chunks over ~8 minutes. Each chunk is a separate bounded delta for bouncers, so the biggest response any bouncer can get from one pull drops by the chunk factor.

One detail worth building in: chunk_interval needs to exceed the fleet's poll interval, or a bouncer whose poll straddles two chunks collects both and the pacing buys nothing.

Why is this needed?

There is currently no way to stop a single blocklist pull from putting the LAPI into an OOM loop.

Ours inserted 89,416 decisions in four seconds on 2026-09-25, one subscribed list accounting for 72,863:

00:58:21Z  lists:firehol_cruzit_web_attacks   13,205
00:58:23Z  lists:crowdsec_cve_2024_4577        3,348
00:58:25Z  lists:crowdsec_cve_2025_55182      72,863
00:59:28Z  OOM: Killed process (crowdsec) anon-rss:19020740kB
01:00:44Z  OOM: Killed process (crowdsec) anon-rss:18953200kB
01:02:06Z  OOM: Killed process (crowdsec) anon-rss:19018436kB

63 seconds from the last insert to the first kill: one poll interval. With ~1.2k bouncers on a 60s poll, every one of them pulled the whole 89k-row delta at once and the engine ran out of memory. It then repeats, because a kill takes every in-flight stream with it and UpdateBouncerStreamPull only runs on a completed response, so no cursor advances and the fleet retries in lockstep.

We already chunk our own cscli decisions import this way — a fixed number of IPs per invocation with a pause between — and it is the only reason importing a 100k list is survivable at this fleet size. The CAPI path has no equivalent seam: updateBlocklist attaches every decision to one alert and saves it in a single call, decision_bulk_size splits the SQL round trips but they run back-to-back so ids come out consecutive, and pull.blocklists is a bool. Unsubscribing from the list is the only lever an operator has.

Related to #4703, which is the same gap on the retention side.

Activity

  1. tommy-ng0 commented on Sep 28, 2026

    @tommy-ng0
    ContributorAuthor

    /kind enhancement

  2. github-actions commented on Sep 28, 2026

    @github-actions

    @tommy-ng0: Thanks for opening an issue, it is currently awaiting triage.

    In the meantime, you can:

    1. Check Crowdsec Documentation to see if your issue can be self resolved.
    2. You can also join our Discord.
    3. Check Releases to make sure your agent is on the latest version.
    Details

    I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

  3. github-actions commented on Sep 28, 2026

    @github-actions

    @tommy-ng0: There are no 'kind' label on this issue. You need a 'kind' label to start the triage process.

    • /kind feature
    • /kind enhancement
    • /kind refactoring
    • /kind bug
    • /kind packaging
    Details

    I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

  4. added
    kind/enhancement
    and removed on Sep 28, 2026
  5. blotus commented on Sep 28, 2026

    @blotus
    Member

    Hello,

    Inserting in chunks feels like putting a band-aid on an open wound, and would make understanding what is blocked at any given time quite hard.

    The decision stream endpoint holds at most one page of 30k decisions per request in memory, and with that many bouncers querying LAPI, it's not surprising to consume that much memory.

    I see potentially 2 solutions (they are not mutually exclusives):

    • Allow to configure the size of the page kept in memory when a request is processed: this would allow reducing the peak memory usage of a single request, at the cost of more DB round-trips
    • Add an option to limit the number of concurrent requests to the decision stream endpoint: if configured, requests would wait until we go below the threshold, which would guarantee the maximum memory usage (at the cost of some request taking longer).
  6. tommy-ng0 commented on Oct 1, 2026

    @tommy-ng0
    ContributorAuthor

    @blotus those solutions sound good to me. Let me know if I can help :)

  7. blotus commented on Oct 16, 2026

    @blotus
    Member

    Closing as #4747 and #4733 have been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementneeds/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions