Tenfold capacity estimation
You can estimate the first bottleneck at ten times current traffic and use that hypothesis to interpret the final local benchmark.
Learning outcomes
- Estimate tenfold peak traffic across the API, MySQL, Redis, the event consumer, and the WebSocket hub.
- Convert request rates into database connection occupancy, commit throughput, Redis operations, memory use, and event backlog.
- Identify the first measured bottleneck while accounting for capacity headroom and workload assumptions.
- Interpret final k6 throughput, latency, error-rate, and hardware measurements without confusing results from different environments.
The final load test can tell you how much traffic the single Go API server handled, but that number alone does not tell you what happens when traffic increases tenfold. You need to estimate the extra work reaching MySQL, Redis, the WebSocket hub, and the event consumer, then compare each workload with a limit measured on the same hardware. The final benchmark also needs enough context to show whether your estimate matched what the system actually did.
Start with the deployment you already have. It has one Go API server, one MySQL primary, Redis, a Redpanda broker, and one worker process. Your mobile application sends browse and order requests, updates rider locations, and maintains WebSocket connections for live order tracking.
The goal is not to guess how many users a server can support. It is to turn a workload into resource consumption and find the component that cannot keep up.
The measured workload
The example uses one specific deployment:
- One Go API running on a 2 vCPU, 4 GB RAM VM.
- One MySQL 8.4 primary running on a separate 2 vCPU, 4 GB RAM VM.
- One Redis 7 instance.
- One Redpanda broker.
- One worker process.
Keep this hardware configuration in view throughout the calculations. The limits below are measurements from these machines. They are not universal limits for Go, MySQL, Redis, or Kafka-compatible brokers.
The measured Friday 8 pm peak workload is:
| Workload | Current peak |
|---|---|
| Browse requests | 120 requests per second |
| Place-order requests | 8 requests per second |
| Rider location updates | 400 updates per second |
| Open WebSocket connections | 1,200 connections |
| Order events sent to Kafka | 8 events per second |
A rate such as 120 requests per second (RPS) describes how quickly work arrives. It is different from a total request count. A k6 run might process thousands of requests over its duration while reporting a much smaller number of requests per second.
The figures above describe a measured peak, not a daily average. If you start with an average workload, you need a peak factor to estimate how much higher the busy period is. For example, a factor derived from the Friday evening peak and the daily average lets you estimate the peak from average traffic.
Do not apply that factor again when your starting figures already represent the measured peak. Doing so would count the same increase twice.
The component measurements from the same deployment are:
| Component | Measured result |
|---|---|
| Go API | 900 browse requests per second before CPU reaches 100 percent, at p95 120 ms |
| Browse cache | 70 percent hit rate |
| MySQL time per browse cache miss | 4 ms |
| MySQL connection pool | 25 connections |
| MySQL primary | 500 commits per second, with 2 ms per commit |
| Redis | 50,000 operations per second |
| Notifier consumer | 300 events per second |
| WebSocket connection | Approximately 40 KB of memory |
These measurements let you compare projected work with a known limit. They do not tell you how every possible workload will behave. A different dataset, query mix, cache state, or request distribution can change the result.
Tenfold traffic
Capacity estimation converts an expected workload into resource consumption on the components that must process it. Start by multiplying each current peak by ten.
Browse requests: 120 × 10 = 1,200 per second
Place-order requests: 8 × 10 = 80 per second
Rider updates: 400 × 10 = 4,000 per second
WebSocket connections: 1,200 × 10 = 12,000
Order events: 8 × 10 = 80 per secondThese rates describe the projected workload. They do not mean that every component receives the same number of operations. A browse request can be served by Redis without reaching MySQL. An order request can execute several SQL statements but commit one transaction. A rider update can involve multiple Redis commands depending on the implementation.
You must translate each workload into the resource it consumes before comparing it with a limit.
The operating rule for this deployment is to plan for no more than 70 percent of a measured limit. This is capacity headroom: the remaining capacity available for traffic variation, background work, and conditions that differ from the benchmark.
For a measured limit of 500 operations per second, the planned operating target is:
500 × 0.70 = 350 operations per secondA workload below the measured maximum can still be too close to saturation for a production target. Keep the measured limit and the safe operating target separate.
API CPU
The Go API is the first component to examine because it receives all the browse requests, including requests that eventually use a cached response.
At ten times the measured browse peak, the API receives 1,200 browse requests per second. The measured API limit is 900 browse requests per second before CPU reaches 100 percent.
Projected browse traffic: 1,200 requests/s
Measured API limit: 900 requests/s
1,200 / 900 = 1.33The projected traffic is about 1.33 times the measured API limit. The server cannot sustain this browse workload on the measured hardware.
You can also calculate the traffic multiplier at which the API reaches its limit:
900 / 120 = 7.5The API reaches its measured browse limit at 7.5 times today's peak traffic.
Apply the 70 percent headroom rule:
900 × 0.70 = 630 requests/s
630 / 120 = 5.25The safe target is 630 browse requests per second, or 5.25 times the current peak. The tenfold workload is well beyond that target.
When CPU reaches 100 percent, incoming work can arrive faster than the process completes it. Requests spend longer waiting to execute. Queues grow, latency rises, and timeouts and errors become more common. The process does not have to crash for the API to become overloaded.
This is the first measured warning in the example. The API's browse workload exceeds its CPU limit before the other calculated resource limits are reached.
A single API server is also a shared resource. Its CPU handles request middleware, routing, authentication, database calls, response serialization, and other application work. A benchmark that tests only browse requests does not prove that the same server can handle the same browse rate while also processing the full order, rider, and WebSocket workload.
Measure the mixed workload before treating the browse-only limit as a guarantee.
MySQL read occupancy
Browse requests do not all reach MySQL. Redis serves cached browse responses, so the database handles only cache misses.
The measured cache hit rate is 70 percent. The corresponding cache hit rate leaves 30 percent of browse requests as misses.
At ten times traffic:
Browse requests: 1,200 per second
Cache misses: 1,200 × 0.30 = 360 per secondEach miss consumes 4 ms of MySQL time. To estimate how many database connections are busy serving those reads, use Little's Law.
Little's Law relates arrival rate, time spent in a system, and the average number of items in that system. For database connections, the useful relationship is:
Busy connections = arrival rate × connection occupancy timeConvert the measured 4 ms into seconds:
4 / 1,000 = 0.004 secondsThen calculate the average number of busy connections:
360 × 0.004 = 1.44 busy connectionsThe projected browse misses occupy approximately 1.44 connections on average.
The pool holds 25 connections. This is the connection limit that matters for connection pool sizing.
1.44 / 25 = 0.0576
0.0576 × 100 = 5.76%The browse-read workload uses approximately 5.76 percent of the pool under these assumptions. The read workload alone does not saturate the connection pool.
Notice what this calculation does and does not tell you. It estimates average connection occupancy from the measured arrival rate and time per miss. It does not predict the exact number of simultaneously busy connections during bursts. It also does not account for connections used by order creation, menu writes, background jobs, or other queries.
The result assumes that the measured 4 ms represents the time each connection remains occupied. If the query takes longer under contention, the occupancy rises. If other endpoints use the same pool, their work must be included before you conclude that the pool has enough capacity.
This is why comparing 360 database requests per second directly with a pool of 25 connections is misleading. Each request occupies a connection for a period of time. Little's Law accounts for that period.
MySQL write throughput
Browse cache misses create read work. Place-order requests create write work.
Today's measured peak is 8 place-order requests per second. At ten times traffic:
8 × 10 = 80 place-order requests per secondThe order creation flow writes the order, its order lines, and its outbox row in one database transaction. The outbox row belongs to the same transaction as the order. This is the transactional outbox pattern.
The transaction contains multiple SQL statements, but they commit together. For this estimate, count one successful transaction commit per placed order. Do not count each inserted row as a separate commit.
80 orders/s × 1 commit per order = 80 commits/sThe MySQL primary sustains 500 commits per second in the measured environment. The projected order workload uses:
80 / 500 = 0.16
0.16 × 100 = 16%The workload uses 16 percent of measured commit throughput.
The safe target is:
500 × 0.70 = 350 commits/sThe projected 80 commits per second are below the 350 commits per second target. Based on this measurement, MySQL write throughput is not the first bottleneck.
The transaction still consumes more than the commit operation itself. SQL statements use CPU, hold locks, and occupy connections. Storage bandwidth and transaction log flushes also matter. A workload can experience slow transactions or lock contention while its raw commit rate remains below the measured maximum.
This is why you need both throughput and latency measurements. A low commit rate does not prove every transaction is fast.
The 2 ms per commit measurement also provides useful context, but it is not a reason to multiply every SQL statement by 2 ms. The relevant unit in this estimate is the transaction commit. Measure the actual transaction duration and database resource use when investigating write pressure.
Redis operations
Redis serves browse cache lookups and receives rider location updates.
At ten times traffic, rider updates increase to:
400 × 10 = 4,000 updates per secondBrowse traffic increases to:
120 × 10 = 1,200 requests per secondAssume one Redis operation for each rider location update and one cache lookup for each browse request.
4,000 + 1,200 = 5,200 operations per secondThe Redis 7 instance sustains 50,000 operations per second in the measured environment.
5,200 / 50,000 = 0.104
0.104 × 100 = 10.4%The projected workload uses 10.4 percent of measured Redis throughput. Its safe target is:
50,000 × 0.70 = 35,000 operations per secondThe estimated 5,200 operations per second are below that target.
This estimate depends on the number of Redis commands per application operation. One rider update might execute a write and an expiry update. A different implementation might perform an additional lookup or metadata update. Those commands all contribute to Redis operation volume.
Do not assume one application request equals one Redis operation. Measure actual command volume under the test workload.
The cache hit rate also affects how much MySQL work reaches the database, but it does not remove the cache lookup itself. At the projected traffic, the API still receives 1,200 browse requests per second even when Redis returns a cached response.
Kafka consumer lag
Order placement produces events for downstream processing. At ten times the current peak, the system produces 80 order events per second.
The notifier consumer processes 300 events per second in the measured environment with one worker process.
Incoming events: 80 per second
Consumer capacity: 300 per second
80 / 300 = 0.267The projected event rate uses approximately 26.7 percent of measured consumer throughput. The safe target is:
300 × 0.70 = 210 events per secondThe projected 80 events per second remain below that target.
A consumer must process events at least as quickly as they arrive over time. When incoming events exceed processing throughput, the unprocessed backlog grows. This is consumer lag.
For example, suppose a worker receives 400 events per second but processes only 300:
400 - 300 = 100 additional events per second
100 × 60 = 6,000 additional events in one minuteThe broker can continue accepting and retaining events while the consumer falls behind. That does not make downstream processing happen on time. A notification can be delayed even though the API successfully placed the order and published its event.
For this deployment, the projected event rate is below the measured consumer throughput. You should still observe lag during the load test because the actual event mix and processing time can differ from the isolated measurement.
WebSocket connections and memory
The mobile app maintains WebSocket connections for live order tracking. Today's measured peak is 1,200 open connections. At ten times traffic, the hub needs to support 12,000 connections.
Each connection consumes approximately 40 KB of memory in the measured environment.
12,000 × 40 KB = 480,000 KB
480,000 / 1,024 = 468.75 MB
468.75 / 1,024 = approximately 0.458 GBThe API VM has 4 GB of RAM. The estimated connection memory is:
0.458 / 4 × 100 = approximately 11.45%Connection memory alone therefore accounts for approximately 11.45 percent of the VM's RAM.
That number does not prove the WebSocket hub can safely support 12,000 connections. The estimate excludes the Go runtime, request buffers, application caches, and other process memory. It also says nothing about the CPU required to read, write, serialize, and distribute messages.
The outgoing message workload needs a separate payload budget. A connection count tells you how many clients are attached. It does not tell you how many bytes the hub sends or how much work it performs for each update.
For example, an update sent to one rider's tracking connection has a different cost from an update broadcast to hundreds of subscribed clients. The relevant outbound workload depends on event rate, recipient count, and message size.
Outbound bytes per second =
events per second × recipients per event × payload bytesMeasure the actual fan-out and payload sizes. Also measure the hub's CPU use, memory, active connections, write queue sizes, and network throughput.
If the hub shares the Go API process, WebSocket activity competes with browse and order requests for resources on the same server. That makes the single-server limit more important, not less. Measure the hub under the same mixed workload before assuming it has independent capacity.
The first bottleneck
The tenfold estimate gives you the following comparison:
| Component | Projected workload | Measured limit | Result |
|---|---|---|---|
| API browse CPU | 1,200 requests/s | 900 requests/s | Exceeds limit |
| MySQL browse reads | 1.44 busy connections | 25 connections | Below pool limit |
| MySQL writes | 80 commits/s | 500 commits/s | Below limit |
| Redis | 5,200 operations/s | 50,000 operations/s | Below limit |
| Notifier consumer | 80 events/s | 300 events/s | Below limit |
| WebSocket connections | 0.458 GB estimated memory | 4 GB VM RAM | Memory estimate below total RAM |
The first bottleneck is the component that reaches its measured limit first as the workload grows. In this example, the API CPU reaches its measured browse limit at 7.5 times today's traffic. The other calculated workloads remain below their measured limits at ten times traffic.
At ten times traffic, browse requests reach 1,200 per second against an API limit of 900. The projected workload is already above that limit, so the API is the first measured component to saturate.
There are important qualifications. The MySQL estimate covers browse-read connection occupancy separately from order writes. The Redis estimate assumes one operation per location update and one lookup per browse request. The WebSocket calculation covers connection memory, not message fan-out or hub CPU. The consumer estimate assumes the measured event-processing rate remains valid for the projected event mix.
These calculations narrow down where to investigate. They do not replace a mixed-workload benchmark.
The first capacity changes
Start with the measured CPU bottleneck. Improving another component does not directly fix a server that is already receiving more browse work than it can process.
A second API instance
Add a second Go API instance with the same relevant hardware and application configuration, then distribute requests evenly through the reverse proxy.
At 1,200 browse requests per second, an even split gives each instance:
1,200 / 2 = 600 browse requests per secondThe original measured limit is 900 requests per second per instance. The safe target is 630 requests per second per instance. At 600 requests per second, each instance is below that target.
This is a direct response to the identified CPU bottleneck.
Do not assume that the whole system's capacity automatically doubles. The load balancer, MySQL, Redis, the WebSocket hub, network resources, and downstream services remain shared dependencies. A second API instance can also increase the number of concurrent database operations and cache requests.
Verify the mixed workload again after adding the instance.
A higher cache hit rate
The browse cache currently serves 70 percent of requests. Suppose you improve the hit rate to 90 percent.
At ten times traffic:
Browse requests: 1,200 per second
Misses at 70% hit rate: 1,200 × 0.30 = 360
Misses at 90% hit rate: 1,200 × 0.10 = 120MySQL misses fall from 360 to 120 per second. That removes 240 browse misses per second from the database workload.
However, the API still receives 1,200 browse requests per second. If the cache lookup happens inside the Go API, every request still enters the server and passes through the work required to reach the cache.
A higher cache hit rate directly reduces MySQL read work. It does not guarantee a reduction in API CPU use.
The result changes if you move caching in front of the API, such as to a reverse proxy or edge cache. Requests served before they reach the Go API can avoid some API processing. Measure the actual path before claiming that a cache improvement raises the API's CPU limit.
Database and Redis changes
The tenfold estimate does not identify MySQL write throughput or Redis operation throughput as the first bottleneck. Do not increase the pool size or replace Redis based only on the request multiplier.
For MySQL, inspect query duration, transaction duration, lock waits, connection occupancy, and storage activity. A larger connection pool can increase database contention instead of improving throughput.
For Redis, measure actual commands per application operation and compare the resulting command rate with the measured limit. If the application performs multiple commands for each rider update, revise the estimate before changing the deployment.
For the WebSocket hub, measure active connections alongside message fan-out, payload sizes, write queues, CPU, memory, and network use. Split the hub from the API only when measurements show that shared processing is creating a real constraint.
Latency and throughput
A capacity measurement needs more than a request rate. An API can complete many requests per second while some users wait much longer than others.
A latency percentile describes the distribution of request durations. A p95 is the latency value at or below which 95 percent of measured requests complete. A p95 of 120 ms means 95 percent of requests completed in 120 ms or less. The slowest 5 percent took longer.
A p99 identifies the corresponding threshold for 99 percent of requests. It exposes more of the slow tail.
The average combines all request durations into one value. A low average can hide a small group of requests taking several seconds because of database contention, garbage collection, or growing queues.
For example, two deployments can have similar average latency while one has a much worse p99. The second deployment can feel slower to users who encounter the tail, even though the averages look similar.
Report average latency and percentiles together. Also report throughput and error rate. A high request rate is not a good result if many requests fail or the slow tail grows beyond an acceptable level.
The final report must identify the hardware behind each measurement. A result of 900 requests per second is incomplete without the CPU, RAM, deployment configuration, and workload that produced it. The same is true of a p95 value.
The final k6 measurements
Run the final browse scenario against the deployment you intend to describe. Keep the API, MySQL, Redis, Redpanda, worker, dataset, and workload characteristics consistent with the deployment being measured.
The k6 --summary-export output contains more metrics than the report needs. The benchmark report package extracts the required values from these metric objects:
http_reqs.count -> Requests
http_reqs.rate -> RPS
http_req_duration.avg -> AvgMs
http_req_duration.p(95) -> P95Ms
http_req_failed.value -> ErrorRateKeep the units consistent. Average and p95 durations remain in milliseconds. The error rate remains a fraction in the parsed Summary. Convert it to a percentage when presenting the report.
For the supplied sample, the parsed values are:
Requests: 18450
RPS: 1230.07
AvgMs: 84.25
P95Ms: 212.44
ErrorRate: 0.00298The error rate is a fraction. As a percentage, 0.00298 is 0.298 percent, which rounds to 0.30 percent. The report rounds RPS to zero decimal places and p95 to one decimal place.
The sample report includes a local run on an M2 MacBook Air with 8 GB of RAM and a server run on a 2 vCPU, 4 GB VM:
| Scenario | Hardware | Requests/s | p95 | Error rate |
|---|---|---|---|---|
| browse local | M2 MacBook Air, 8 GB | 1230 | 212.4 ms | 0.30% |
| browse server | 2 vCPU, 4 GB VM | 450 | 380.0 ms | 0.00% |
These rows show why the hardware column matters. The local run and server run have different throughput and latency results. You cannot treat the faster local result as the capacity of the server VM.
The sample report values are also not interchangeable with the earlier API measurement of 900 browse requests per second at p95 120 ms. That measurement describes a particular load test and deployment condition. The sample report describes separate runs with their own hardware labels and test results. Before comparing them, verify that the request mix, data, cache state, and test conditions match.
The benchmark report table includes the fields required by the benchmark report package: request rate, p95, error rate, and hardware. The parsed summary also retains the total request count and average latency. The package's required table does not include p99. Do not claim that its table contains a p99 result. When the README reports p99 as part of the broader performance discussion, take that measurement from the k6 results separately.
Benchmark interpretation
Treat the estimate as a hypothesis to test, not a guarantee. The final k6 run tells you how the actual system behaved under the measured conditions. Compare that behavior with your calculated limits.
Look for the first component approaching its measured limit:
- If API CPU reaches 100 percent while browse traffic rises, the single API server is behaving as predicted by the estimate.
- If MySQL connection occupancy approaches 25, investigate the actual cache miss rate, query duration, and concurrent database workload.
- If MySQL write latency rises, inspect transaction duration, locks, and the actual commit rate rather than counting inserted rows as commits.
- If Redis command volume is much higher than the estimate, count the commands performed by each application operation.
- If notifier lag grows, compare the actual incoming event rate with the consumer's processing rate.
- If WebSocket latency or dropped connections increase, inspect hub CPU, memory, message fan-out, payload size, and network throughput.
The first failure can differ from the estimate because multiple workloads interact. For example, order placement and WebSocket traffic can consume API resources while browse traffic is arriving. MySQL reads and writes also share the same primary, so their combined effect can exceed what either isolated calculation suggests.
A useful benchmark answers three questions. What workload did you run? What did the system measure? Which resource approached its limit first?
Common estimation mistakes
Comparing request rates with connection counts. A rate of 360 database misses per second does not mean 360 connections are required. Connections are occupied for a duration. Ignoring that duration leads to an incorrect pool estimate.
Counting SQL statements as commits. The order transaction inserts multiple records, including the outbox row, but those writes commit together. Counting each insert as a separate commit overstates the transaction commit rate.
Treating every cache hit as an API request avoided. A cache lookup inside the Go API still requires the request to reach the API. The hit reduces database work, but the incoming request rate remains the same.
Treating the measured maximum as a safe target. The API's 900 requests per second is the measured point where CPU reaches 100 percent. It is not the target you should plan to sustain. The 70 percent headroom rule gives a target of 630 requests per second.
Using connection memory as the whole WebSocket budget. The 40 KB estimate covers memory per connection. It does not cover the full CPU, network, and message-processing cost of the hub.
Comparing benchmarks from different machines. A faster result on a laptop does not establish the capacity of a smaller server VM. Hardware and test conditions belong beside every result.
Reading only the average latency. An average can hide slow requests. If p95 or p99 rises sharply, the service can be degrading even when average latency remains acceptable.
The benchmark report package
The benchmark report package turns the final k6 summary into typed measurements and a Markdown table. Its report keeps the scenario and hardware beside the request rate, p95, and error rate, so the README can explain where each number came from.
Keep parsing separate from presentation. The summary represents the measured values. The table represents how you communicate them. Missing metrics, malformed JSON, an empty run list, or a missing hardware description should not silently produce a plausible-looking report.
The report is evidence for your capacity argument, not a replacement for it. Use the measured numbers to validate or revise your estimates, explain which component becomes constrained first, and defend the first change you would make. The benchmark should make that explanation reproducible for someone reading the project documentation.
Check your understanding
The API handles 120 browse requests per second at the measured Friday peak. Its measured CPU limit is 900 browse requests per second. At what multiple of the current peak does the API reach that limit?
References
Everything above is explained on this page; these are where it comes from.