Skip to content

Capacity planning ​

This section provides guidance on sizing disk, memory, CPU, and database resources based on registry type and expected usage.

Artifact storage sizing ​

Artifact size varies dramatically by ecosystem. Use these typical values to estimate max_artifact_size_bytes and total storage needs:

Registry typeTypical artifact sizeRecommended max_artifact_size_bytes
npm50 KB – 5 MB50 MiB
Cargo100 KB – 10 MB50 MiB
PyPI (wheel)1 MB – 100 MB200 MiB
Maven (JAR)1 MB – 200 MB256 MiB
NuGet100 KB – 50 MB100 MiB
Conda50 MB – 500 MB512 MiB
Docker (layer)1 MB – 2 GB4 GiB
JetBrains IDE500 MB – 2 GB4 GiB
Debian / RPM100 KB – 500 MB512 MiB
Terraform provider5 MB – 100 MB256 MiB

For a proxy-only deployment: size storage at (unique packages cached) × (average artifact size) × (versions per package). A practical starting point for a small team is 100 GB.

For a local-mode deployment: add the total size of all artifacts you plan to publish, and keep a separate backup (see disaster recovery).

Memory ​

BatleHub's in-process memory use is low (< 200 MB baseline). Most memory is consumed by:

  • The metadata cache (configurable TTL; use [cache] type = "redis" to offload it).
  • Per-request buffering for streaming large artifacts.

Recommended minimum: 512 MB RAM for a small deployment. For high concurrency (> 100 simultaneous downloads), allocate 2 GB to accommodate in-flight buffers.

CPU ​

BatleHub is I/O-bound, not CPU-bound. Even a 2-core instance handles several hundred requests/second for cached artifacts. CPU spikes occur during:

  • SBOM extraction (ZIP decompression + JSON serialization).
  • TLS termination (offload to a reverse proxy / load balancer for very high traffic).
  • Vulnerability scanning (periodic, not on the hot path).

Recommended: 2–4 vCPUs for most deployments.

What security gates cost a request ​

Measured with perf/scripts/gate_levels.sh (2026-11-09, release build, mock upstream, 50 req/s per request shape): the median latency of eight download and metadata requests, at five levels of gating. Each level adds rules to every registry, all set to allow the traffic, so the number is the cost of evaluating the gates on a request that passes.

LevelRulesAdded median latencyFirst download of a new version
none—— (≈ 5 ms per download, 1.3 ms per packument)served at once
minrelease_age_gate+0.0 to +0.2 msserved at once (if old enough)
medium+ cve_gate+0.0 to +0.4 msserved at once
high[registries.security] (osv) + cve_gate+0.3 to +0.65 msheld until the scan answers: ~9 s
maxhigh + license_gate, version_gate, require_signed_release, SBOM+0.2 to +0.75 msheld until the scan answers: ~10 s

Run to run, the same level moves by up to ±0.15 ms. The per-request cost of every level is below a millisecond. What a level really costs is the hold: a [registries.security] profile serves a version only once its required scanners have answered (here, OSV over the network plus the worker's 2-second poll), and a release_age_gate or security.min_age_secs holds a version younger than its age, which is hours or days by design. Plan for the hold, not for the CPU.

What a cold fill costs ​

A cold miss writes the artifact to storage as 8 MiB segments, then turns them into the blob; with several replicas the others follow the fill from storage.

ResourceCost
StorageThe artifact twice on S3 (segments + blob) from assembly until the segments are deleted; once on the filesystem
MemoryOne segment (8 MiB) per running fill on the replica that holds it, plus one read chunk per reader
S3 requestsPer GiB filled: 128 PutObject + 128 UploadPartCopy + 128 DeleteObject; each reader on another replica, 128 GetObject
PostgreSQLAbout 133 statements per 1 GiB fill (one per segment, plus ~5); none on an idle server, none at all with a memory cache

Leave free storage for the largest artifacts filling at once, twice over on S3.

Database (PostgreSQL) ​

  • Connections: Default max_connections = 20 per instance; see sizing max_connections before going higher. The DB itself should allow at least max_connections * (number of instances) + 10 headroom.
  • Disk: The access_events table grows ~1 KB per event. At 1,000 events/day, that is ~365 MB/year. Schedule periodic purges: batlehub-cli audit purge --before 2024-01-01T00:00:00Z.
  • IOPS: Metadata reads and record_access writes are the hottest paths. An SSD with 3,000 IOPS is sufficient for most teams.

Set per registry, not globally, to avoid a large JetBrains IDE download from blocking smaller npm installs that share a connection pool:

toml
[[registries]]
name = "npm-proxy"
type = "npm"
[registries.local_registry]
max_artifact_size_bytes = 52428800   # 50 MiB

[[registries]]
name = "jetbrains-proxy"
type = "jetbrains"
[registries.local_registry]
max_artifact_size_bytes = 4294967296  # 4 GiB

Released under the Apache 2.0 License. Made with care and too much coffee.