#4711·crowdsec

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

Author: tommy-ng0Created Sep 28, 2026Updated Oct 1, 2026
Labelskind/enhancementneeds/triage

/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:

yaml
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.