Skip to content

Scaling

Avinash Gupta edited this page Oct 18, 2026 · 1 revision

Scaling

Going from one database to every database: across regions, across accounts, and past what one process handles. For per-database throughput (busy files, backfills, tuning knobs) see Performance and Throughput.

The limits that matter

Limit Value Scales with
Instances per rdstail process 500 (validated at startup and after every discovery pass) more processes (--shard)
RDS log-API calls ≈ 14/s per account + region, shared by all callers more accounts/regions, longer or adaptive polling
Read speed per log file 0.3–0.9 MB/s nothing; reduce volume at the source

The second row is the one people hit. More rdstail processes don't raise it.

1. One region: discover everything

sources:
  - type: rds
    region: us-east-1
    discover:
      all: true                       # every MySQL / MariaDB / PostgreSQL / Aurora instance
      exclude_tags: {rdstail: "off"}  # opt a database out by tagging it
      refresh_interval: 5m            # new DBs start, deleted DBs stop, automatically
  • Engines are detected per instance, so one source covers a mixed fleet.
  • On every refresh, workers start for new instances and stop for departed ones. Their checkpoints are kept, so a database that comes back resumes. A failed discovery call keeps the current set; it never tears workers down.
  • Prefer opt-in by tag? Use discover: {tags: {rdstail: "on"}} instead of all: true. Tags are AND-ed.
  • Preview the result before running: rdstail discover -c rdstail.yaml.

2. Many regions

sources:
  - type: rds
    regions: [us-east-1, eu-west-1, ap-south-1]   # expands to one source per region
    discover: {all: true, refresh_interval: 5m}

Each region has its own API budget, so regions scale independently. Running one process for all regions is fine. Data is pulled cross-region over the RDS API, so there's no VPC peering to set up. The S3 sink writes to one bucket region; cross-region transfer applies to bytes shipped.

3. Many accounts

One rdstail in a central (logging/security) account, one source block per member account:

sources:
  - type: rds
    regions: [us-east-1, eu-west-1]
    discover: {all: true}                                  # this account
  - type: rds
    regions: [us-east-1]
    assume_role: arn:aws:iam::222222222222:role/rdstail-reader
    discover: {all: true}
  - type: rds
    regions: [us-east-1]
    assume_role: arn:aws:iam::333333333333:role/rdstail-reader
    discover: {all: true}

In each member account, create rdstail-reader with the RDS read actions (rds:DescribeDBInstances, rds:DescribeEvents, rds:DescribeDBLogFiles, rds:DownloadDBLogFilePortion), trusting the central account's rdstail role. Deploy it with a StackSet or Terraform across the organization. rdstail iam-policy -c rdstail.yaml prints the central role's policy, including the sts:AssumeRole statements.

Each account + region pair has its own API budget, so multi-account fleets scale well.

4. Sharding

For more than 500 databases, or to isolate parts of the fleet.

Run n processes with the same config, each told its share:

rdstail run -c rdstail.yaml --shard 1/3    # host / pod A
rdstail run -c rdstail.yaml --shard 2/3    # host / pod B
rdstail run -c rdstail.yaml --shard 3/3    # host / pod C
  • Assignment is rendezvous hashing on region + instance ID. Every process computes the same answer independently, with no coordination service, and each database is tailed by exactly one shard.
  • Each shard needs its own state.path. In Kubernetes, use one Deployment + PVC per shard, each with its own --shard i/n argument (or RDSTAIL_RUNTIME__SHARD=i/n).
  • Changing n moves only ~1/n of the databases. A database that moves starts on its new shard per start_from. Use beginning, or copy its rows from the old shard's state.db, to avoid a gap.
  • Shards share each account + region's API budget. Splitting a 600-database region into 3 shards needs the same poll_interval you'd need for 600 in one process.

Isolation without sharding: separate configs per team or environment (different instance sets, sinks and state files) are just separate rdstail processes. Use this when teams need different destinations or poll rates.

5. Fleet-size presets

Rough guides for one account + region, assuming error + slow logs. Validate with rdstail cost-estimate and the throttling metric.

Fleet (per account+region) Suggested runtime
≤ 30 DBs defaults (poll_interval: 10s)
30–150 DBs poll_interval: 15s, poll_interval_max: 2m
150–400 DBs poll_interval: 30s, poll_interval_max: 5m, checkpoint_retention: 168h
400+ DBs in one region poll_interval: 60s, poll_interval_max: 10m; shard past 500; consider splitting accounts

Adaptive polling (poll_interval_max) matters most at scale. Most databases are quiet most of the time; they back off exponentially and snap back to the base rate on the first new line.

6. Scaling the destinations

Sink At scale
S3 Scales effortlessly. Use lifecycle rules (→ Glacier IR after 30–90 days) and Athena for queries
Kafka Partition count ≥ concurrent busy files; key is instance|log_file
HTTP Check the vendor's rate and payload limits; filter to ERROR+ for expensive per-GB vendors and archive everything to S3
Loki stack Single-node Loki suits tens of databases with error/slow/audit logs. Beyond that, run Loki in its scalable mode or keep Loki for alerts (filtered) and S3 for the archive

Checklist

  • rdstail discover lists exactly what you expect in each region/account
  • Per account + region: estimated calls/s under ~14, minus other API consumers
  • poll_interval_max set for fleets with idle databases
  • Shards: same config, distinct state.path, --shard i/n on each
  • rdstail_api_calls_total{outcome="throttled"} alert in place (Monitoring)

Clone this wiki locally