Under the hood
How one Rust process receives, symbolicates, groups and commits error events, why it terminates its own TLS and keeps events in Postgres, which event stores we measured against each other, and the limits of the setup.
App Monitoring speaks the Sentry protocol, so the official SDKs work unchanged, but behind the URL
there is no Sentry: one Rust binary accepts the envelope, matches source maps, groups the event
into an issue and commits it, and answers 200 only after the commit. The decision that shapes it
is that the path from the wire to an issue is one process and one batch window, not a chain of
queues. The second decision is where events live: in Postgres today, measured against two
alternatives, with our own segment store staged behind it.
What runs where
How events are received describes the ingest from the SDK's side. Inside, on each control-plane machine:
SDK / browser / tunnel ─▶ errors.<domain>:443
▼
Caddy :443 reads the ClientHello only; SNI = errors host
│ passes the TCP connection unopened + PROXY v2
▼
errors-ingest (2 replicas per machine, 2 CPUs each)
rustls, h2 and HTTP/1.1
accept: key cache → rate limit → decompress → parse
process: normalise → symbolicate → group → zstd
write: 4 writers, one transaction per 25 ms or 500
▼
Postgres telemetry database ── 200 after COMMIT
(day partitions, drop = expiry)
▼ staged, not read by customers yet
own segment store on object storageEach replica is one process with a bounded queue: a request waits up to 2 s for a slot, then gets
429. Symbolication runs before grouping, so two builds of the same code land in one issue.
Writers are sharded by project and fingerprint, so a storm of one error costs one row lock per
25 ms. The DSN key table sits in memory, reloaded every 5 s. Per-minute rate limits are shared by
all replicas through a table synced about four times a second. At shutdown a replica serves open
requests for 10 s, keeps writing acknowledged events until 35 s, then spills the rest to disk and
replays it at the next start. There are two replicas per machine because an SDK does not retry an
envelope a restarting ingest refused, so a rollout replaces them one at a time.
Events are stored once, as zstd-compressed normalised JSON, partitioned by day of receipt and sub-partitioned by retention, so expiry is a partition drop; the issue list reads counters kept per issue and per hour, never the events.
What we built, and what we did not
One process instead of a pipeline. Sentry's path is Relay, Kafka, an ingest consumer, a
symbolicator and post-processing, each hop with its own batching. We wrote one Rust binary
(10,786 lines, 64 tests) that accepts, symbolicates and writes the issue in the same 25 ms batch,
so event-to-issue latency is a function of the batch window. We did not evaluate self-hosted
Sentry or Relay in writing, nor measure a Node ingest against the Rust one; the language was a
standing preference for new hot paths. GlitchTip (MIT) was read for ideas, not vendored. The
protocol pieces are off the shelf: getsentry's sourcemap and js-source-scopes crates, swc's
parser for original function names, hyper, rustls, tokio-postgres, zstd.
The ingest terminates its own TLS. Every hostname on a control machine shares one Caddy capped at 2 CPUs. Under SDK load that Caddy was the ceiling while the ingest replicas idled at 17 to 32 %, and the console's p95 behind the same Caddy went from 19 ms to 518 to 1,012 ms. We rejected more Caddy CPUs (5,000 events/s would need 5 to 14 Caddy cores, and console and ingest would still share one saturated process), a second Caddy for the errors host (the same per-core cost, still an L4 split), the ingest on an address of its own (a DNS change, one host port per replica; the next step if needed) and an ingest-only DSN host (every DSN changes). Instead Caddy's listener reads the ClientHello (caddy-l4) and passes a connection for the errors host unopened, with a PROXY v2 header, to a replica, which terminates with rustls. The certificate stays Caddy's: a small Caddy module of ours exports only that host's certificate and key to a volume the ingest reads.
Postgres for events, then our own segment store. We first chose Postgres over ClickHouse ("a second stateful system to run HA, back up, upgrade and secure") and over files on object storage ("we would be writing a database; the issue list still needs a mutable store"). Then we measured: a 50-million-event bake-off (below) of our own segment store, Postgres and ClickHouse, each doing the production writer's full issue-side work. The own store won on cost and on every product read except ad-hoc group-bys over non-tag fields, where only ClickHouse stays flexible. What the bake-off changed: our store gets no durability of its own. Postgres stays the store of record; each complete UTC day of a project is compacted into dictionary-compressed 64-event blocks with an index and a tag sidecar, uploaded, read back and verified event by event before it is recorded. Today the builder runs in shadow in our test installation only, and the reader is checked against Postgres there; no customer read comes from segments yet. If this fails at scale, the fallback is ClickHouse, not a bigger Postgres.
Acknowledge after commit. SDKs drop a refused envelope and back off, so "acknowledged then lost" must be zero: the ingest answers after the commit, and at stop spills what the database could not take to an fsynced file. That cost throughput against the first version, which answered at the queue; the numbers below are the version that ships.
Telemetry beyond errors: no database of our own. Asked whether to build "our own telemetry database" for logs and traces, we measured Postgres 17, ClickHouse 26.8 and a DataFusion 55 + Parquet prototype on the same 20 M spans and 10 M logs (below). The gap between DataFusion and ClickHouse was exactly what a store must build: a text index, a compactor and a cache, 12 to 16 engineer-weeks to reach roughly what GreptimeDB already is. So telemetry stays in Postgres with day partitions, with per-minute rollups decided but not built yet; when logs and traces become a product, the destination is ClickHouse, single node first, fed through the same Postgres staging as the segment store; our own Parquet writer exists only as a future archive tier. Loki, Tempo and Mimir are AGPL; Quickwit's team now belongs to Datadog; InfluxDB 3 Core's compactor is paid; GreptimeDB has been 1.x only since April 2026. None was chosen.
Benchmarks
How to rerun these. The TLS edge table comes with oha commands, reconstructed because the exact
flag lines were not kept. The event store bake-off and the telemetry store bench were run with an
internal tool, not published; the engines, images, schemas and data shape are given, enough to
rebuild the method. The scripts of the ingest throughput run, the kill -9 runs and the
segment-read proof were not kept.
TLS edge, before and after (2026-11-19). Load from a dedicated-8 (8 dedicated AMD vCPU,
32 GB) in zone de1a to our test installation's control machine, a performance-8 (8 shared AMD
vCPU, 16 GB); Caddy capped at 2 CPUs, two ingest replicas at 2 CPUs each; oha 1.8.0, 30 s runs, a
1,600-byte envelope (one error, 8 frames), TLS 1.3; a console probe of 10 authenticated API reads
per second through the same Caddy. Raw output not kept.
| Mode | Before: Caddy terminates | After: ingest terminates |
|---|---|---|
| HTTP/1.1 keep-alive, 64 conns | 1,352 ev/s, p50/p95 46/69 ms | 1,314 ev/s, 46/59 ms |
| HTTP/1.1 keep-alive, 512 conns | 2,039 ev/s, 106/956 ms, Caddy 195 %, console 1,012 ms | 5,834 ev/s, 72/147 ms, Caddy 51 %, console 22 ms |
| HTTP/2, 32 conns × 16 streams | 1,773 ev/s, 129/984 ms, console 707 ms | 5,822 ev/s, 69/160 ms, console 19 ms |
| New TLS connection per event, 256 conns | 694 ev/s, 303/792 ms, 2,572 errors | 2,945 ev/s, 82/122 ms, 0 errors |
# the exact flag lines were not kept; these reproduce the recorded modes
oha -z 30s -c 512 -m POST -D envelope.bin -H 'X-Sentry-Auth: Sentry sentry_key=<key>' \
https://errors.<domain>/api/<project>/envelope/
oha -z 30s -c 32 -p 16 --http2 ... # 16 streams per connection
oha -z 30s -c 256 --disable-keepalive ...At 64 connections the limit is commit latency (about 46 ms, Little's law), not the proxy. One machine, one data centre: it shows the proxy's cost per core, not internet latency.
Ingest throughput, answer after commit (2026-11-19). Same performance-8, one replica at
2 CPUs, k6 constant-arrival-rate on the same machine, one error event per request, 30 s. Raw
output not kept.
| Answer | Offered | Achieved | p50 / p99 answer | Stored |
|---|---|---|---|---|
| at queue | 4,000/s | 4,000/s (100 %) | 0.22 / 3.8 ms | |
| after commit | 4,000/s | 3,908/s (100 %) | 63 / 262–271 ms | 235,047 = 235,047 answered |
# our k6 script was not kept; it was a constant-arrival-rate scenario,
# one ~1.6 KB envelope per request, POST /api/<project>/envelope/ with X-Sentry-Auth
k6 run -e RATE=4000 -e DURATION=30s envelope.jsThe ingest used 87 % of its 2 CPUs. An earlier run the same day reached only about 1,980/s and is
unexplained; an older 5,000/s figure for one replica was measured with the answer at the queue.
Under kill -9 three times at 2,000/s: 119,119 answered 200, 119,142 stored, 0 acknowledged
events lost.
Event store bake-off, 50 M events (2026-11-19). One VM with 8 vCPU, 32 GB and a 272 GB disk
(Ubuntu 24.04, x86_64, Xeon D-2141I) on one of our own hosts; one store at a time, all on the one
disk. 50 M generated events from 20 projects with Zipf-distributed issue counts, templated from 81
real JavaScript, Node and Python SDK events, median 7.5 to 9 KB of JSON, 30 days. Every candidate's
write included the production writer's Postgres work (issue upsert, hourly counters, users, outbox,
usage) and acknowledged only when durable; 4 writers; batches of 500 (A, B) and 5,000 (C). The
load generator is an internal tool, not published; the stores are postgres:17 and
clickhouse/clickhouse-server:26.8.40.7. Raw output not kept.
| 50 M events | A: own segment store | B: Postgres 17 | C: ClickHouse 26.8 |
|---|---|---|---|
| Ingest, events/s (median of 5 s windows) | 8,593 (7,780) | 7,447 (7,292) | 6,892 (6,986) |
| Bytes per event on disk | 722 | 3,825 | 495 |
| Read by id, p50/p99 warm | 2.3 / 3.5 ms | 12 / 18 ms | 59 / 94 ms |
| Top-10 tag facet, 14 days, 12.2 M-event project | 3.4–6.6 ms | 8.7–8.8 s | 242–266 ms |
| Substring search, 14 days, same project | 3.1 s (payload) | 7.3 s (titles) | 2.4 s (payload) |
kill -9 mid-load, 3 runs, acknowledged lost |
0 | 0 | 0 |
| Storage per billion events a month, 90 days | about €80 | about €1,310 | about €180 |
Costs use our list prices for database storage, volumes and object storage, two copies where a host loss must not lose data. A is fast only for time, issue and the precomputed tag facets: a group-by on another payload field is a full scan, about 3 s per 12 M events. On the real object storage in our test installation (2026-11-20, 100,000 random reads, raw output not kept), segment reads by id are p50 50 ms and p99 417 ms, not the 3.5 ms of the local-disk run; a block cache is needed before customers read from segments.
Telemetry store bench, logs and traces (2026-11-20). Our shared arm-16 test machine (16
Neoverse-N1 cores, 32 GB), each engine given 6 CPUs (Postgres and ClickHouse in containers with
8 GB, DataFusion as one process with 6 partitions), one at a time, load 2
to 4 from other work during the run (read ±20 % into any single number). 20 M OpenTelemetry-like
spans (14 columns) and 10 M logs, 20 tenants, Zipf sizes, 30 days. Postgres 17 with day
partitions, btree on (tenant, ts) and trace id, trigram index on log bodies; ClickHouse 26.8.40.7
MergeTree ordered by (tenant, ts), bloom filter on trace id, token index on bodies; DataFusion 55.3
over Parquet (zstd 3, 64 k row groups, one file per tenant, signal and day) on a local SeaweedFS,
plus runs with 50 ms added per object-storage request, the latency class of HDD-backed object
storage. Raw output is kept, and every number below was re-checked against it.
| Bytes per row on disk | Postgres | ClickHouse | Parquet |
|---|---|---|---|
| spans | 237 | 35 | 28 |
| logs (with search index) | 370 | 48 | 36 |
| Warm p50, largest tenant, ms | Postgres | ClickHouse | DataFusion local | +50 ms per request |
|---|---|---|---|---|
| p95 by route, 7 days (1.27 M root spans) | 550 | 50 | 138 | 1,214 |
| one trace by id, no time bound | 6.2 | 31 | 55 | 1,089 |
| rare token in 7 days of logs | 2.5 | 10 | 88 | 501 |
| full scan, p95 by service, 20 M spans | 11,603 | 86 | 758 | 6,927 |
Real spans carry many more attributes, so absolute bytes are low for every store and the ratios are what carries over. Single queries, no concurrency, synthetic rows. Postgres wins every indexed lookup; ClickHouse wins every aggregation; DataFusion on object storage without a cache loses to both. The load tool is an internal tool, not published; the engines, schemas and images are public.
Known limits
- Overload loses events: after the 2 s wait the ingest answers
429, and SDKs do not retry. - Not supported: span streaming, mobile replays, cron check-ins, logs, feedback, metrics; each is answered with a one-hour rate limit so the SDK stops sending.
- Session replay segments wait in a queue of their own (16 MiB per replica). When it is full the
oldest segment is dropped and counted (
lost:queue_full), so a slow object store costs replay seconds, never errors. - A burst shorter than one rate-limit sync (about 250 ms) can pass a little over the limit.
- With a new TLS connection per event Caddy still spends 137 to 161 % CPU on accept and copy, about 3.6k events/s in that mode; there is a connection cap but no per-IP handshake limit.
- Postgres as event store: tag facets take 4 to 9 s and search covers titles only on large projects; a single-event read without the day in the link probes every partition (19 ms instead of 2.3 ms). The telemetry database is a single node without failover.
- Several writers can deadlock on one project's issues with big batches; the batch is retried.
- Per-project daily and stored-bytes caps are not built. A disk guard refuses everything from 80 % of the telemetry database's capacity and releases below 75 %.
- No OTLP logs or traces endpoint, no protobuf; the rollups are decided, not built.