Scaling and Amdahl’s law
We ask which work can run independently. A larger fleet cannot remove a serial dependency by itself. We will compare scaling directions, expose state placement, and calculate the bound from serial work.
#Section 21Vertical versus horizontal scaling
Heron can move a database to a larger machine or add application instances. Vertical scaling gives a machine more resources. Horizontal scaling distributes work across more machines. Each solves a capacity problem only when the added resource serves the limiting work.
A larger machine keeps local state and coordination in one place. It can enlarge memory for cached pages, add compute, or provide stronger storage. Its limits include the available machine size, the downtime or migration needed to change it, and the consequences of losing that machine. A single hot lock can remain serial on a larger host.
More application instances distribute independently executable requests. They introduce load routing, connection budgets, deployment coordination, and more copies of local state. When state is shared in a database, the database must absorb the combined demand. Adding callers can therefore worsen the exact bottleneck you hoped to remove.
Choose the smallest change that addresses measured demand. If page misses are the limit and a larger memory tier contains the working set, vertical scaling may be enough. If independent application CPU work is the limit, additional instances may distribute it. Explain the failure behavior and state boundary alongside the capacity benefit.
#Section 22Stateless requests and shared state
A load balancer sends successive score reads to different Heron workers. A stateless request handler can complete a request using its input and shared services without requiring an earlier request to have reached the same worker. This property makes routing and replacement simpler, but the system still has state somewhere.
Move durable score records and session validation behind explicit shared contracts. Local caches may differ temporarily, so define how stale they may be and how they refresh. A worker can disappear without deleting the authoritative score. Its in-flight requests may still need retry or cancellation handling.
Now count the shared limits. Five illustrative instances with 20 database pool slots each offer 100 simultaneous operations. Doubling application instances while leaving per-instance pools unchanged doubles that offered concurrency. The database does not gain service capacity merely because the callers became easier to replace.
State placement also controls failure blast radius. A per-worker live connection belongs to that worker until reconnect; it cannot become stateless by naming the application tier stateless. A gateway needs reconnect and subscription recovery rules. State which parts can move freely and which require replay, reattachment, or coordination.
#Section 23Partitioning and hot work
One match attracts most of Heron’s viewers while other matches are quiet. Partitioning divides data or work into separately owned subsets. It can make independent owners scale, but one popular key can still overload its owner while the fleet average looks comfortable.
Choose the unit that can run independently. Different matches may have independent score histories, while events within a single match need an order. Adding partitions for quiet matches does little for one match’s write sequence. Viewer delivery, however, can distribute recipients across gateways without reordering the authoritative match updates.
Splitting a hot key changes the read plan. A latest-score value is easy to replicate as a derived read copy; an ordered event history may need multiple ranges merged or a sequencer retained. Count the extra messages and define which owner enforces the invariant. Distribution changes the work as well as the location.
A cache or replica can spread reads when staleness permits. Writes that update one invariant need a coordination rule even when clients run everywhere. Explain which part of the operation is parallel and which must remain ordered. That answer determines whether horizontal scaling is possible or only creates more contention.
#Section 24Amdahl’s law, step by step
An illustrative Heron maintenance job takes 100 ms on one worker. It spends 20 ms in a serial step and 80 ms in work that can divide perfectly across workers. Amdahl’s law bounds speedup for a fixed workload with that unchanged serial fraction.
With four workers, parallel work takes ms, so total time is ms. Speedup is . With eight workers, parallel work takes 10 ms, total time is 30 ms, and speedup is 3.3333, rounded to four decimals. The serial 20 ms does not divide.
Read this as: speedup with workers is the reciprocal of serial fraction plus parallel fraction divided by worker count . Here . With unlimited ideal workers, parallel time approaches zero and speedup approaches .
The model omits added communication, scheduling, and contention, so measured speedup can be worse. It also assumes the same job rather than a larger workload. Increasing throughput by processing more independent jobs is a different question from shortening one job's serial critical path. State which outcome the calculation predicts.
#Section 25Reducing the serial fraction
After adding eight workers, the maintenance job still spends most of its remaining duration in the serial step. More workers have diminishing benefit because they reduce the smaller remaining parallel component. The next useful action is to inspect why the serial step exists.
Some order is essential, such as applying one match's updates in sequence. Other serial work comes from an avoidable shared lock, repeated setup, or a central queue. Separate the invariant from its current implementation. Sharding independent match ownership can preserve each match's order without serializing unrelated matches together.
For a second illustrative fixed-work comparison, reduce the serial fraction to 0.1 while keeping normalized one-worker work equal to one. With eight ideal workers, speedup becomes , rounded to four decimals. This illustrates the effect of the fraction; it does not claim an implementation change costs no work.
Measure the revised job from start to finish. Removing a lock can add coordination elsewhere, and splitting work can increase total CPU even when wall time improves. Keep wall-clock duration, total service demand, and useful throughput as separate outcomes. The fastest design for one request is not automatically the least expensive design for a whole workload.