Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Heuristic:Huggingface Datatrove Thundering Herd Prevention

From Leeroopedia
Knowledge Sources
Domains Distributed_Systems, Optimization
Last Updated 2026-02-14 17:00 GMT

Overview

Randomized start delay technique (up to 180 seconds) that prevents thousands of SLURM tasks from simultaneously hitting S3 or shared storage, avoiding thundering herd bottlenecks.

Description

When a SLURM job array with thousands of tasks starts, all tasks attempt to access the shared filesystem or S3 storage at the same moment. This simultaneous access creates a "thundering herd" pattern that overwhelms storage backends, causing timeouts, throttling, and cascading failures. The solution is to add a configurable random delay (`randomize_start_duration`) before each task begins processing, spreading the initial load over a time window.

Usage

Use this heuristic when running large-scale distributed pipelines (1000+ tasks) that access shared storage (S3, NFS, Lustre) during startup. This is especially important for Common Crawl processing, FineWeb dataset creation, and any pipeline that reads many files from the same storage backend. The delay should be proportional to the number of tasks and the storage backend's throughput limits.

The Insight (Rule of Thumb)

  • Action: Set `randomize_start_duration=180` (3 minutes) in the `SlurmPipelineExecutor` for large-scale jobs.
  • Value: Each task sleeps a random duration between 0 and 180 seconds before starting work. With 8000 tasks, this spreads the initial I/O load over a 3-minute window instead of a single spike.
  • Trade-off: Adds up to 3 minutes of idle time per task. For long-running tasks (hours), this overhead is negligible. For short tasks (minutes), consider a smaller delay.

Scaling guidance:

  • 100 tasks: `randomize_start_duration=30` (30 seconds)
  • 1000 tasks: `randomize_start_duration=60` (1 minute)
  • 8000 tasks: `randomize_start_duration=180` (3 minutes, FineWeb production value)

Reasoning

Cloud storage backends (S3, GCS) and shared filesystems (NFS, Lustre) have throughput limits. When thousands of tasks simultaneously issue `list` and `read` operations, the storage backend becomes the bottleneck. S3 specifically throttles requests per prefix, returning 503 SlowDown errors. NFS may deadlock under extreme concurrent access.

The FineWeb dataset production pipeline uses 8000 parallel tasks. Without staggering, all 8000 tasks would simultaneously attempt to list and read WARC files from S3, causing widespread timeouts. A 180-second random delay spreads these 8000 initial requests over a 3-minute window, giving approximately 44 requests per second instead of 8000 at once.

Code evidence from `src/datatrove/executor/base.py:55,125-126`:

randomize_start_duration: int = 0,
...
if self.randomize_start_duration > 0:
    time.sleep(random.randint(0, self.randomize_start_duration))

Production usage from `examples/fineweb.py:65-69`:

tasks=8000,
...
randomize_start_duration=180,

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment