Skip to content

Performance and Throughput

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

Performance and throughput

rdstail itself is rarely the bottleneck. The RDS log API is. This page explains the limits, how to size a deployment, every tuning knob, and what to do for the common high-volume situations.

The three stages and what bounds each

 RDS log API ──────────────▶ rdstail ─────────────▶ sink
 ① per-file read speed       ③ CPU, memory,          ④ S3 PUTs / Kafka /
 ② per-account call budget     state store              HTTP receiver / pipe
# Limit Typical value Symptom when hit
① Read speed of one log file. DownloadDBLogFilePortion is sequential per file 0.3–0.9 MB/s (≈ 1–3 GB/hour) per file, content-dependent One busy file falls behind while others are fine
② Log-API calls per account + region, shared by every caller (rdstail shards, other tools, the console) ≈ 14 successful calls/s sustained rdstail_api_calls_total{outcome="throttled"} rises; every DB's latency grows
③ rdstail process far above ①/②: parsing and gzip are cheap next to the API's ~1 MB/s High CPU only with many parallel_reads_per_file readers
④ Sink S3/Kafka: far above ①; HTTP and pipes depend on the receiver rdstail_sink_write_duration_seconds climbs, retries, DLQ

Measured examples (us-east-1, live RDS):

  • A 6-hour rdstail dump of a busy MySQL 8.4 slow-query log, 117 MB raw, took ~6 minutes: ≈ 0.33 MB/s sequential, at the low end of ①.
  • parallel_reads_per_file: 8 drained a 276 MB PostgreSQL file at ~1.2 MB/s vs ~0.86 MB/s sequential on a db.t4g.small (≈ 1.4×; the RDS per-call latency rises with concurrency).
  • End-to-end latency at poll_interval: 5s, unthrottled: p50 ≈ 3.5 s, p95 ≈ 6–8 s.

The rule that follows: any single log file that grows faster than ~0.3 MB/s (~1 GB/hour) sustained cannot be tailed in real time by any tool using the RDS API. Error, slow-query (sensible thresholds) and DDL/DCL audit logs are orders of magnitude below that. general_log, log_statement = all, and audit logs with DML/reads on a busy database are not.

Sizing

1. Measure your volume first

rdstail cost-estimate --region us-east-1             # every instance in the region
rdstail cost-estimate -c rdstail.yaml --json         # exactly what a config would ship

This reads file sizes from DescribeDBLogFiles (free, nothing downloaded) and projects monthly volume per instance.

2. Check the per-file limit (①)

Divide each instance's busiest log type by the hour. PostgreSQL writes one file per hour; MySQL rotates its general/slow logs hourly.

Busiest file grows at Verdict
< 100 MB/hour Comfortable; real-time with defaults
100 MB – 1 GB/hour Fine; consider parallel_reads_per_file: 4 for catch-up after outages
> 1 GB/hour sustained Lag will grow during peaks. Reduce volume at the source

3. Check the API budget (②)

Each poll of an instance costs one DescribeDBLogFiles, plus one DownloadDBLogFilePortion per file that has new data, plus one more per extra MB. rdstail also makes one DescribeEvents call per region per minute.

calls/s ≈ Σ over instances of (1 + files with new data) / poll_interval
          + total MB/s shipped
Fleet poll_interval Approx. calls/s Verdict
50 PostgreSQL (≈ 2 calls/poll) 30 s 3.3 fine
50 MySQL with error + slow + general (≈ 4 calls/poll) 10 s 20 throttled; use 30 s or adaptive polling
300 mostly idle DBs 10 s, poll_interval_max: 5m low once idle DBs back off fine

Rough ceilings per account + region before throttling:

poll_interval MySQL instances PostgreSQL instances
5 s ~15 ~30
30 s ~100 ~200
60 s ~200 ~400

Sharding (--shard i/n) does not raise this ceiling: all shards share the account's budget. Splitting across accounts or regions does.

Tuning knobs

All under runtime: unless noted. Defaults are right for most fleets; change one thing at a time and watch the metrics below.

Knob Default Raise / set it when Cost
poll_interval 10s Lower (≥ 1s) for fresher alerts on a few DBs; raise for big fleets More API calls per second
poll_interval_max 0 (off) Any fleet with idle databases. Idle DBs back off up to this ceiling and snap back on the first new line Worst-case extra latency after idle = one backed-off interval
poll_backoff_multiplier 2.0 Rarely n/a
max_workers 5 Many busy files lag while throttled stays ~0 More concurrent API calls; more memory
parallel_reads_per_file 1 (off), max 32 One big file is behind (catch-up after an outage, start_from: beginning, busy hour) N× calls for that file; burns API budget fast
max_batch_bytes / max_batch_records 5 MiB / 10000 Lower for HTTP receivers with payload caps; raise for fewer, larger S3 objects Bigger batches = more memory, bigger re-send on crash
max_instances_concurrent 0 (one worker per instance) Leave at 0. A value below the instance count leaves instances unpolled n/a
shard / --shard i/n none > 500 instances per process, or isolation between teams One state file per shard
start_from end beginning to backfill retained logs on first sight (combine with parallel_reads_per_file) Backfill time = retained MB ÷ ~0.5 MB/s per file
checkpoint_retention 0 ≥ 24h on fleets with hourly-rotated files, so the state DB stays small n/a
sink retry.* 10 attempts, 0.5 s → 60 s ×2 Lengthen for flaky receivers before the DLQ catches it Longer stalls per file during outages
sink filter none Send only ERROR+ to expensive destinations, everything to S3 n/a

Note: runtime.memory_budget_bytes is accepted by the config loader but not enforced by the current release. Bound memory with max_workers and the batch sizes instead (below).

Memory, roughly: each file being drained holds up to one batch (max_batch_bytes, which can overshoot by one ~1 MB chunk) as parsed records plus its encoded copy during the write, and parallel reads add up to N × 2 MB per wave. Concurrency is capped by max_workers. With defaults that's tens of MB at peak; measure the process RSS on your workload before lowering limits.

Reduce volume at the source

The highest-leverage tuning happens in the DB parameter group, not in rdstail. Every byte you don't log is a byte you don't download, ship, store or pay for.

PostgreSQL

Parameter Recommendation
log_statement ddl (not all; mod only if you need DML and can afford it)
log_min_duration_statement ≥ 1000 ms in production; 0 logs every statement
pgaudit.log ddl,role; add write only where required; avoid read and all
log_connections / log_disconnections off on high-connection-churn apps without a pooler
auto_explain.log_min_duration high (≥ 5 s) if auto_explain is loaded; plans are large
log_lock_waits, log_temp_files (e.g. 10240 kB), log_autovacuum_min_duration (e.g. 10s) cheap and useful: keep them

MySQL / MariaDB

Parameter Recommendation
general_log 0 in production; use the audit plugin with narrow events instead
long_query_time ≥ 1 (seconds); 0 turns the slow log into a general log
log_queries_not_using_indexes 0, or bound it with log_throttle_queries_not_using_indexes
min_examined_row_limit e.g. 1000 to skip cheap slow statements
SERVER_AUDIT_EVENTS (audit plugin) CONNECT,QUERY_DDL,QUERY_DCL; add QUERY_DML only if required
SERVER_AUDIT_EXCL_USERS rdsadmin (RDS's own monitoring queries)
log_error_verbosity 2; 3 adds notes such as Access denied (needed for MySQL failed-login detection without the audit plugin)

Slow logs can contain very large single records. Bulk INSERTs of several hundred KB are common, and rdstail caps a multi-line record at 1 MiB. Large records are mostly a sink concern (see Kafka below).

Sinks at volume

S3: each flush is one PUT of gzipped NDJSON. Batching at 5 MiB keeps request costs negligible (~$0.005 per 1,000 PUTs) and objects large enough for Athena/Spark. Lower max_batch_bytes only for fresher objects. S3 latency is ~50–200 ms per PUT and is never the bottleneck.

Kafka: acks=all, idempotent producer, zstd/snappy compression. The message key is instance|log_file, so one file's records stay ordered on one partition, and a single hot file is limited to one partition's throughput (far above ①). Make sure the topic's max.message.bytes (and the broker's message.max.bytes) is at least 2 MB. Multi-line records can approach 1 MiB, and a record the broker rejects ends up in the DLQ after retries.

HTTP: one POST per batch (JSON array). Set max_batch_bytes / max_batch_records under the receiver's payload cap, leaving ~1 MB of headroom for chunk overshoot (e.g. Datadog: 1000 events / ~5 MB → 500 records / 3 MiB). A 4xx (413 Payload Too Large, 401) goes straight to the DLQ without retrying; a 5xx or timeout retries with backoff. gzip: true cuts egress ~5–10× for remote receivers.

stdout (pipes): rdstail checkpoints when the write to the pipe succeeds, so the consumer (vector, fluent-bit) owns durability from there: enable its disk buffer. A slow consumer back-pressures rdstail through the pipe. That's safe (nothing is dropped), but it shows up as lag.

Fan-out: every sink receives every record. Sinks are written one after another, and the checkpoint advances only after all of them have succeeded or parked the batch in the DLQ. One slow sink slows the whole pipeline, so put slow or remote receivers behind a filter, or run them from a second rdstail process with its own state file.

State store

SQLite in WAL mode with one writer: one small write per checkpoint advance, negligible at RDS-API speeds.

  • Keep state.path on local disk (EBS, a PVC). Never on NFS/EFS: SQLite locking over network filesystems is unreliable.
  • One state file per process. Every shard needs its own.
  • Set checkpoint_retention: 168h (or run rdstail state gc) on fleets with hourly-rotated files; otherwise the checkpoint table grows by one row per file per hour.

Playbooks

One busy database falls behind

  1. Check which file: rdstail_ingestion_lag_seconds{instance="…"} by log_file, and rdstail cost-estimate -i <db>.
  2. If it's general/audit/log_statement=all: reduce at the source (above). This is the real fix.
  3. For catch-up after an outage: parallel_reads_per_file: 4–8, watching throttled.

Large fleet, mostly quiet

runtime:
  poll_interval: 15s
  poll_interval_max: 5m     # idle DBs poll every 5 min; first new line → back to 15s
  checkpoint_retention: 168h

Throttling across the fleet (outcome="throttled" > 0 for minutes)

  1. Raise poll_interval or enable poll_interval_max.
  2. Look for other RDS log-API consumers in the account (other tools, scripts, a second rdstail without --shard).
  3. rdstail already backs off: throttled instances double their interval with ±20 % jitter (up to 2 min) and the AWS SDK rate-limits adaptively. Nothing is lost; only latency rises.

Backfill retained logs on day one

runtime:
  start_from: beginning
  parallel_reads_per_file: 8
  max_workers: 5

Budget the time: retained MB ÷ (~0.5–1 MB/s per file). Then remove parallel_reads_per_file once caught up so live tailing doesn't burn the API budget.

More than 500 databases: --shard 1/3, 2/3, 3/3 on three hosts, each with its own state.path. Remember shards share the per-account API budget, so lengthen poll_interval accordingly.

Fresher alerts on a few critical databases: run a second rdstail with those instances, poll_interval: 2s, a webhook sink filtered to min_severity: ERROR, and its own state file. Keep the bulk fleet on the slower main process.

What to watch

Full metric list, alert rules and dashboard: Monitoring.

The ops dashboard and alert rules cover these. The key PromQL:

# API budget used (compare with ~14/s per account+region)
sum(rate(rdstail_api_calls_total{outcome="ok"}[5m]))

# Throttling: anything sustained above 0 means you're at the ceiling
sum(rate(rdstail_api_calls_total{outcome="throttled"}[5m]))

# Sink health
histogram_quantile(0.99, sum by (le, sink_type) (rate(rdstail_sink_write_duration_seconds_bucket[5m])))
max(rdstail_dlq_depth) > 0

# Adaptive polling at work
rdstail_poll_interval_seconds

# Read problems: gaps, stalls, truncated lines, restarts
increase(rdstail_read_anomalies_total[1h]) > 0

rdstail_ingestion_lag_seconds compares the file's LastWritten with local time. An idle database looks "behind" too, so treat it as a smoke signal, not a page.

Checklist before going to production at volume

  • rdstail cost-estimate run; no file sustained above ~1 GB/hour
  • general_log off, long_query_time ≥ 1, audit events narrowed
  • calls/s estimate under ~14 per account + region (minus other consumers)
  • poll_interval_max set if any databases are idle for long periods
  • HTTP batch sizes under the receiver's cap; Kafka topic accepts 2 MB messages
  • state on local disk, one file per process/shard, checkpoint_retention set
  • alerts on DLQ depth, throttling and read anomalies

Clone this wiki locally