The concept Quantify the workload first
A customer says: The system works, but it cannot keep up with our volume. Quantify the workload before recommending optimization or a new architecture. Ask how many transactions a day, the average and peak rates, whether traffic is even or spiky, the processing window, acceptable end-to-end latency, how much history must be kept, and how fast the system must recover after an outage.
Worked example Average versus peak
| Step | Calculation | Result |
|---|---|---|
| Daily volume | Given by Apex (example) | 120,000 payment events a day |
| Average rate | 120,000 ÷ 86,400 seconds | about 1.39 events a second |
| Observed peak | Given by Apex (example) | 20 events a second |
| One consumer's capacity | Measured in a representative test (example) | 10 events a second |
| Gap at the peak | 20 needed, 10 available | One consumer is not enough at the peak |
Latency Percentiles beat averages
End-to-end latency for a payment includes provider delivery, API processing, queue waiting, consumer work, database work, downstream delay and the reconciliation schedule. Measure the whole journey as well as each part. Use percentiles:
| Percentile | Meaning |
|---|---|
| p50 | The median: half of requests are faster |
| p95 | 95% of requests finish within this time |
| p99 | 99% finish within this time: the slow tail |
A low average can hide a serious tail. If 1 payment in 100 takes 30 seconds, the average barely moves, but every morning hundreds of payments are late.
Calculate percentiles from the raw timings, not from averages of averages. Here are 1,000 end-to-end timings from one fictional morning. The query sorts them and reads the value at each rank (the nearest-rank method: p95 is the value at position 950 of 1,000):
sqlAverage versus percentiles on 1,000 payment timings
WITH ranked AS (
SELECT
latency_ms,
ROW_NUMBER() OVER (ORDER BY latency_ms) AS position,
COUNT(*) OVER () AS n
FROM payment_latency
)
SELECT
MAX(n) AS payments,
ROUND(AVG(latency_ms)) AS avg_ms,
MAX(CASE WHEN position = (n * 50 + 99) / 100 THEN latency_ms END) AS p50_ms,
MAX(CASE WHEN position = (n * 95 + 99) / 100 THEN latency_ms END) AS p95_ms,
MAX(CASE WHEN position = (n * 99 + 99) / 100 THEN latency_ms END) AS p99_ms,
SUM(latency_ms > 10000) AS over_10_s
FROM ranked;Result on the sample
payments avg_ms p50_ms p95_ms p99_ms over_10_s
-------- ------ ------ ------ ------ ---------
1000 1924.0 1525 2339 26962 15Real output from SQLite 3.54 on 1,000 fictional timings generated by tools/fde/apex_latency.sql, November 22, 2026.
Read it the way a customer will feel it. The average is under 2 seconds and p95 is 2.3 seconds, so a dashboard of averages says all is well. But p99 is 27 seconds, and 15 payments in 1,000 took over 10 seconds. If the sample's rate held at Apex, the morning window would hold about 720 slow payments: 15 ÷ 1,000 × 48,000 = 720, where 48,000 is the events between 8:00 and 10:00 a.m. (40% of 120,000, from the exercise below). That is an estimate from a fictional sample, not a measurement; measure the real tail before quoting it. That tail is where the investigation starts: which step were those 15 payments waiting on?
Storage Estimate storage growth
| Step | Calculation | Result |
|---|---|---|
| Daily raw data | 120,000 events × 2 KB | about 240 MB a day |
| Yearly raw data | 240 MB × 365 | about 87.6 GB a year |
| Units used | Decimal: 1 KB = 1,000 bytes, 1 MB = 1,000 KB, 1 GB = 1,000 MB |
The 2 KB is the average event payload as received, measured from a sample (an assumption to confirm with Apex). It does not include database row overhead, indexes or processing metadata such as event IDs and timestamps added on the way. So this is raw data only. Real storage grows with indexes, metadata, replicas, retention periods, compression and backups, so treat it as a starting estimate.
Commitments Availability and recovery
| Term | Meaning |
|---|---|
| Availability | How much of the time the service must be usable |
| RTO (recovery time objective) | How quickly service must be restored after an outage |
| RPO (recovery point objective) | How much data, measured in time, may be lost |
| Backup and restore | How data is copied and how long restoring takes |
| Fallback | The manual procedure when the system is down |
Practice Size the morning peak
Practical exercise
Can the current setup cope?
Apex tells you 40% of the 120,000 daily events arrive between 8:00 and 10:00 a.m., and the busiest minute inside that window reaches the observed peak of 20 events a second from the table above. Two consumers each handle 10 events a second, sharing one database that handles 15 writes a second.
- Work out the average rate in that two-hour window.
- Find the limiting component.
- Say what you would measure next.
Show the worked answer
- Events in the window: 120,000 × 40% = 48,000. Over 7,200 seconds that is about 6.7 events a second. That is the average across the two hours, not the peak.
- The peak is a separate number: 20 events a second in the busiest minute, observed by Apex. Averages over a long window always hide the busiest minute, so ask for both.
- Consumers: 2 × 10 = 20 a second; the database: 15 a second. The 6.7 average fits easily, but at the 20-a-second peak the database falls behind by about 5 writes a second, so the database is the limit. How long the peak lasts decides how big the backlog grows.
- Measure next: the real peak minute, database write latency and lock waits at the peak, and queue depth from 8:00 to 10:00.
3 questions
Check your understanding
What you can do now
- Calculate average and peak throughput.
- Find the limiting component in a processing chain.
- Use percentiles to describe latency.
- Estimate storage growth and ask for availability and recovery objectives.