ArchitectMind
  1. Home
  2. Java Ecosystem
  3. Book 7 · Application Architecture & Distributed Systems
  4. Volume VII
  5. Scalability
Book 7 · Volume VII — Resilience, Scalability & Distributed Data · Topic 1.1

Scalability

Vertical and horizontal scaling

18 min readStage 3 · Systems8 interview questions
Chapter
Chapter 1 — Scalability Architecture
Prerequisites
Volume V (microservices), Volume VI Chapter 2 (Kafka partitions)
You will be able to
Define scalability precisely, compare vertical and horizontal scaling by cost, limits and failure behaviour, explain why speed-up flattens using Amdahl and the USL, apply the scale cube, and choose a scaling strategy per tier of a Java/AWS system
Covers
Vertical; Horizontal
On this page
  1. 1. Concept / Definition
  2. 2. Why It Exists
  3. 3. Core Concepts
  4. 4. How It Works Internally — Why Speed-Up Flattens
  5. 4A. Deep Dive — The Scale Cube
  6. 5. APIs / Features / Syntax
  7. 6. Practical Examples
  8. 7. Common Problems & Mistakes
  9. 8. Performance & Production Considerations
  10. 9. Architecture & Design Considerations
  11. 10. Interview Questions & Answers

1Concept / Definition

Scalability is a system's ability to handle increased load — more users, requests, data or work — by adding resources, while keeping performance within targets and cost roughly proportional. Vertical scaling adds resources to a single node; horizontal scaling adds more nodes that share the work.

Vertical (TOC) vs horizontal (TOC) scaling
Figure 1 — Vertical (TOC) vs horizontal (TOC) scaling
TOC dimensionDefinition
VerticalScaling up: increasing a node's CPU, memory, disk or network (e.g., m7i.large → m7i.8xlarge, db.r7g.xlarge → db.r7g.8xlarge). Simple and transparent to software, but bounded by the largest machine, priced super-linearly at the top end, and still a single point of failure
HorizontalScaling out: adding identical instances behind a load balancer or partitioned data across nodes. Near-linear capacity and built-in redundancy, but requires stateless services or data partitioning and introduces coordination costs
Table 1 — The two TOC dimensions

2Why It Exists

Load grows — seasonally (sale days), steadily (business growth) and suddenly (a viral product). A system that can only grow by rewriting will fail commercially before it fails technically.

Cost vs capacity
Figure 2 — Cost vs capacity

3Core Concepts

3.1 Vertical

Vertical scalingDetail
When it shinesDatabases, single-writer components, legacy monoliths, in-memory analytics
Java considerationsLarger heaps → use generational ZGC; more cores → virtual threads help I/O-bound work
AWS mechanicsChange instance type (stop/start or Aurora failover to bigger reader)
CeilingLargest instance (e.g., 192+ vCPU); licence and cost cliffs
RiskOne node = one failure domain; resize windows
Table 2 — Scaling up
YAML
# Kubernetes: vertical scaling of a pod = bigger requests/limits (VPA can recommend)
resources:
  requests: { cpu: "2",  memory: "4Gi" }
  limits:   { cpu: "4",  memory: "4Gi" }
env:
  - name: JAVA_TOOL_OPTIONS
    value: "-XX:MaxRAMPercentage=75 -XX:+UseZGC -XX:+ZGenerational"

3.2 Horizontal

Vertical vs horizontal scaling
Figure 3 — Vertical vs horizontal scaling
YAML
# Horizontal: more replicas spread across zones
apiVersion: apps/v1
kind: Deployment
metadata: { name: checkout }
spec:
  replicas: 12
  template:
    spec:
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: topology.kubernetes.io/zone
          whenUnsatisfiable: DoNotSchedule
          labelSelector: { matchLabels: { app: checkout } }
Horizontal prerequisiteWhy
Stateless instances (Topic 1.2)Any node can serve any request
Load balancing (Topic 1.3)Spread work evenly
Partitionable dataDatabases/queues must split too
Idempotent operationsRetries across nodes
AutomationMany nodes need automated deploy/scale
Table 3 — Scaling out
How each tier scales
Figure 4 — How each tier scales
Tier at ShopNowTodayScale-up optionScale-out optionChosen
Checkout service12 pods × 2 vCPU4 vCPU podsUp to 60 podsScale out (HPA)
Catalogue service6 pods—Pods + CDN cachingScale out + cache
Aurora writerdb.r7g.2xlargeup to 16xlargePartition orders by customerUp now, partition later
Aurora readers2—Up to 15 replicasScale out
Redis3 shardsBigger nodesMore shardsScale out
Kafka orders topic24 partitionsBigger brokersMore partitions/brokersPartitions sized for 2 years
Table 4 — Scaling decisions per tier
JAVA
// Scaling efficiency from load-test runs: throughput per node should stay flat
record Run(int nodes, double rps) {}
static void efficiency(List<Run> runs) {
    double base = runs.getFirst().rps() / runs.getFirst().nodes();
    for (Run r : runs) {
        double eff = (r.rps() / r.nodes()) / base;          // 1.0 = perfectly linear
        System.out.printf("%2d nodes: %6.0f rps, efficiency %.0f%%%n",
                r.nodes(), r.rps(), eff * 100);
    }
}

4How It Works Internally — Why Speed-Up Flattens

Throughput vs nodes (Universal Scalability Law)
Figure 5 — Throughput vs nodes (Universal Scalability Law)
LawFormulaMeaning
AmdahlS(N) = 1 / (s + (1 − s)/N)Serial fraction s caps speed-up at 1/s
USLC(N) = N / (1 + σ(N−1) + κN(N−1))Contention σ and coherency κ can make more nodes slower
Table 5 — Scalability laws
Source of σ (contention)Source of κ (coherency)
Single DB writer, global locksCache invalidation broadcasts
Shared sequence generatorsDistributed transactions
Hot partitions/keysCluster membership chatter
Table 6 — Where the limits come from

4ADeep Dive — The Scale Cube

Scale cube (AKF)
Figure 6 — Scale cube (AKF)
Scaling a typical stack
Figure 7 — Scaling a typical stack
AxisShopNow exampleLimit
X (clone)12 checkout podsShared DB
Y (function)Checkout, catalogue, search servicesCross-service calls
Z (data)Orders sharded by customer; cells by regionCross-shard queries
Table 7 — Applying all three axes

5APIs / Features / Syntax

NeedTooling
Scale up podsrequests/limits, VPA recommendations
Scale out podsDeployment replicas, HPA
Scale nodesKarpenter / managed node groups
Scale DBAurora instance class, read replicas, partitioning
Scale messagingKafka partitions + consumers
Table 8 — Toolkit

6Practical Examples

6.1 Scaling the database last

ShopNow scaled checkout from 4 to 40 pods for a sale; throughput rose only 2.5× because Aurora's writer hit 95% CPU. The fix combined a larger writer (vertical), moving reads to replicas (horizontal) and batching inventory updates.

6.2 Scale-up that saved a quarter

A reporting monolith couldn't be split before year-end. Moving it to a 4× larger instance with ZGC bought six months while the team extracted services.

6.3 Worked example — Amdahl

Serial 5%Max speed-up 20×
Table 9 — Hard ceiling

Scenario. ShopNow's nightly price recalculation took four hours on one node. The team planned to run it on 50 nodes and expected it to finish in about five minutes.

Walkthrough. Amdahl's Law says the speed-up from parallelism is limited by the part of the work that must run serially. Profiling showed about 5% of the job was serial: loading reference data, a final consolidation step and writing a summary. With a serial fraction of 5%, the maximum possible speed-up is 1 / 0.05 = 20 times, however many nodes are added. Fifty nodes would give roughly 14 times, not 50.

Result. The team ran the job on 16 nodes, which gave most of the achievable gain, and then halved the serial part by loading reference data in parallel, which raised the ceiling to 40 times.

Takeaway. Measure the serial fraction before adding nodes. Reducing serial work often helps more than adding hardware, because it raises the ceiling on every future speed-up.

6.4 Worked example — USL retrograde

σ=0.05, κ=0.002Peak ~20 nodes, then declines
Table 10 — More isn't better

Scenario. ShopNow's search cluster got faster as nodes were added up to about 20, but adding more nodes after that made throughput go down, which surprised the team.

Walkthrough. The Universal Scalability Law extends Amdahl's Law with a coherency term, κ, for the cost of nodes coordinating with each other, such as cache invalidation or cluster state updates. Fitting measurements gave σ = 0.05 for contention and κ = 0.002 for coherency. With these values, throughput peaks at around 20 nodes and then declines, because each additional node adds more coordination work than capacity.

Result. The team capped the cluster at 18 nodes and reduced coordination by sharding the index, which lowered κ and allowed further growth with separate smaller clusters.

Takeaway. More nodes are not always better. Measure the scaling curve, fit contention and coherency, and redesign to reduce coordination before scaling beyond the peak.

6.5 Worked example — cost comparison

Option₹/month for 32 vCPU
1 × 32 vCPUhigher per vCPU at top sizes
8 × 4 vCPUlinear, plus LB
Table 11 — Price per unit

Scenario. ShopNow needed 32 vCPUs for its order service and compared one large instance with eight smaller ones.

Walkthrough. Cloud pricing is roughly linear in the middle of the range, but the very largest instance sizes often cost more per vCPU and are less available. Eight 4-vCPU instances cost about the same per vCPU as mid-size instances, plus a load balancer. They also give redundancy: losing one instance removes an eighth of capacity, not all of it, and capacity can grow in small steps.

Result. ShopNow chose eight smaller pods behind a load balancer, with autoscaling between six and twelve, which reduced both cost and risk compared with one large instance.

Takeaway. Compare price per unit of capacity and failure impact, not only total size. Horizontal scaling usually wins for stateless services; vertical scaling suits stateful components that are hard to distribute.

6.6 Worked example — read replicas

Reads 80% of DB load3 readers → writer freed
Table 12 — Horizontal for reads

Scenario. ShopNow's PostgreSQL writer was running at 85% CPU. Analysis showed that 80% of its load came from read queries, such as product pages and order history.

Walkthrough. Read replicas receive changes from the writer and serve read-only queries. The team added three Aurora reader instances and routed read-only transactions to the reader endpoint, while writes stayed on the writer. Reads that need the very latest data, such as showing an order just placed, still go to the writer, because replicas can lag slightly.

JAVA
@Transactional(readOnly = true)   // routed to the reader endpoint
public Page<OrderSummary> history(CustomerId id, Pageable page) {
    return orders.findSummariesByCustomer(id, page);
}

Result. Writer CPU dropped to about 30%, giving room for write growth, and read latency improved because load was spread across three readers.

Takeaway. Scale reads horizontally with replicas when reads dominate. Route by transaction type, and be explicit about which reads can tolerate replica lag.

6.7 Worked example — hot key

One seller = 30% of writesPartition fails to spread
Table 13 — Z-axis skew

Scenario. ShopNow partitioned its marketplace order data by seller ID to spread writes across shards. One very large seller, responsible for 30% of all writes, overloaded a single shard.

Walkthrough. Partitioning, the z-axis of the scale cube, works only if load spreads evenly across partitions. A hot key, here one dominant seller, concentrates load on one partition regardless of how many partitions exist. The fix was to partition that seller's data by a composite key, seller ID plus order ID hash, so its orders spread across several shards.

Result. Write load evened out across shards, and the overloaded shard's latency returned to normal. Monitoring now alerts when any partition receives disproportionate traffic.

Takeaway. Choose partition keys by how load is distributed, not just by data ownership. Watch for hot keys and have a strategy for splitting them.

6.8 Worked example — virtual threads

I/O-bound serviceMore concurrency per pod
Table 14 — Better vertical use

Scenario. ShopNow's notification service spent most of its time waiting on email and SMS providers. Each pod handled only 200 concurrent requests because it used a fixed pool of 200 platform threads.

Walkthrough. For I/O-bound work, virtual threads let each pod handle many more concurrent requests, because a blocked virtual thread does not hold an operating-system thread. Enabling them in Spring Boot required one property, and the existing blocking code stayed unchanged.

YAML
spring:
  threads:
    virtual:
      enabled: true

Result. Each pod handled several thousand concurrent requests with the same CPU and memory, so the service needed far fewer pods during peaks.

Takeaway. Before adding nodes, make better use of the ones you have. Virtual threads are an easy vertical efficiency gain for I/O-bound Java services.

6.9 Worked example — heap sizing

8 GiB podMaxRAMPercentage=75
Table 15 — Container-aware JVM

Scenario. ShopNow moved its catalogue service to 8 GiB pods, but the JVM still used only about 2 GiB of heap and frequently ran garbage collection.

Walkthrough. Without explicit settings, the JVM sets the maximum heap to 25% of the container memory. Setting -XX:MaxRAMPercentage=75 lets the heap grow to about 6 GiB while leaving room for metaspace, thread stacks and other native memory. Because the setting is a percentage, it adjusts automatically if the pod size changes.

YAML
env:
  - name: JAVA_TOOL_OPTIONS
    value: "-XX:MaxRAMPercentage=75 -XX:+UseG1GC"
resources:
  limits: { memory: 8Gi }

Result. GC frequency dropped sharply and throughput per pod rose, so vertical scaling to larger pods actually delivered its expected benefit.

Takeaway. When scaling a JVM vertically, make sure it can use the extra resources. Container-aware settings such as MaxRAMPercentage are essential.

6.10 Worked example — Kafka

12 partitionsMax 12 active consumers per group
Table 16 — Partition ceiling

Scenario. To clear a backlog, ShopNow scaled an order-event consumer from 12 to 30 pods. Throughput did not improve at all.

Walkthrough. In Kafka, each partition is consumed by at most one consumer in a group. The topic had 12 partitions, so only 12 consumers could be active; the other 18 sat idle. The partition count sets a ceiling on consumer parallelism for a group.

BASH
kafka-consumer-groups.sh --bootstrap-server $BROKER \
  --describe --group order-events-processor
# 12 partitions assigned, 18 consumers with no partition

Result. The team increased the topic to 48 partitions for future growth, accepting a rebalance and ordering considerations, and the backlog cleared with 30 consumers.

Takeaway. Plan Kafka partition counts for future consumer parallelism. Adding consumers beyond the partition count does nothing.

6.11 Worked example — scaling test

1, 2, 4, 8 podsMeasure throughput curve
Table 17 — Find σ, κ

Scenario. ShopNow's architects wanted to know how the order service would behave at three times current load, instead of guessing.

Walkthrough. The team ran the same load test with 1, 2, 4 and 8 pods, measuring maximum throughput at acceptable latency for each. Plotting throughput against pod count and fitting the Universal Scalability Law gave values for contention and coherency. Near-linear growth means low σ and κ; flattening reveals contention, such as a shared database.

Result. Throughput grew almost linearly to 4 pods, then flattened because of database contention, which showed that the next investment should be in the database, not more pods.

Takeaway. Measure the scaling curve with controlled tests before making capacity plans. The shape of the curve tells you where the bottleneck is.

6.12 Worked example — global lock

Synchronized order-number generatorSerial bottleneck → use sequences/ULIDs
Table 18 — Remove contention

Scenario. Order throughput at ShopNow stopped increasing beyond 400 orders per second, no matter how many pods were added.

Walkthrough. Profiling showed every pod waiting on a synchronized method that generated sequential order numbers from a shared counter row. That global lock serialised all order creation. Replacing it with database sequences, which allocate numbers without long locks, or with ULIDs, which are generated locally without coordination, removed the serial bottleneck.

JAVA
// Before: one global lock across the cluster
// synchronized OrderNumber next() { return counterRepo.incrementAndGet(); }
// After: no coordination needed
OrderId id = OrderId.of(UlidCreator.getMonotonicUlid().toString());

Result. Throughput scaled again with pods, reaching 1,500 orders per second in the next load test.

Takeaway. Look for global locks and shared counters when scaling stalls. Removing contention is often the single biggest scalability improvement.

6.13 Worked example — cache coherency

Local caches invalidated via broadcastκ grows with N
Table 19 — Coherency cost

Scenario. ShopNow's pricing pods each kept a local cache and broadcast invalidation messages to all other pods whenever a price changed. Adding pods made the system slower.

Walkthrough. Each price change produced one message per pod, so the coordination traffic grew with the number of pods, and every pod spent more time processing invalidations. This is the coherency cost, κ, in the Universal Scalability Law. Moving to a shared Redis cache with short time-to-live values removed the need for pods to coordinate with each other.

Result. Pricing scaled linearly again, and cache consistency improved because all pods read the same cached values.

Takeaway. Coordination between nodes limits scalability. Prefer designs where nodes do not need to talk to each other, such as shared caches or partitioned data.

6.14 Worked example — cells

Customers split into 4 cellsIndependent scaling & blast radius
Table 20 — Z-axis

Scenario. A single faulty deployment at ShopNow once affected every customer at the same time. Leadership asked for a way to limit the impact of failures and scale more predictably.

Walkthrough. ShopNow split customers into four cells, each a complete, independent copy of the platform serving a quarter of customers, with its own databases and queues. A thin routing layer sends each customer to their cell. Deployments roll out cell by cell, and each cell scales independently.

Result. A later bad deployment affected only the first cell and was rolled back before reaching the others. Capacity planning also became simpler, because each cell has a known maximum size.

Takeaway. Cell-based architecture applies the z-axis of the scale cube to the whole platform. It limits blast radius and makes growth predictable by adding cells.

6.15 Worked example — node types

Graviton (m7g) vs x86Better price/perf for Java
Table 21 — Vertical economics

Scenario. ShopNow's finance team asked whether the platform could reduce compute costs without changing application code.

Walkthrough. The team load-tested its Java services on Graviton (arm64, m7g) instances and on comparable x86 instances. For most services, Graviton delivered similar or better throughput at a lower hourly price. Multi-architecture images allowed the same deployment to run on both types during migration.

Result. Moving most services to Graviton cut compute costs by roughly 20% with no code changes. A few services with native libraries stayed on x86 until arm64 builds were available.

Takeaway. Vertical economics matter: the same capacity can cost very different amounts on different instance types. Test price-performance regularly.

6.16 Worked example — quotas

vCPU quota per regionRequest increase before sale
Table 22 — Hidden ceiling

Scenario. During ShopNow's first big sale on the new platform, autoscaling stopped adding nodes at peak traffic. The cluster had reached the account's regional vCPU quota.

Walkthrough. Cloud accounts have service quotas, such as the maximum number of vCPUs per instance family in a region. They are invisible until hit, and increases can take days to approve. After the incident, ShopNow added quota checks to capacity planning and requested increases well before each sale.

BASH
aws service-quotas get-service-quota \
  --service-code ec2 --quota-code L-1216C47A   # Running On-Demand Standard vCPUs

Result. The next sale scaled to twice the previous peak without hitting any quota.

Takeaway. Include cloud quotas in capacity plans. A hidden ceiling outside your system can stop scaling as surely as a software bottleneck.

6.17 Worked example — batch

Spring Batch partitioned stepHorizontal workers
Table 23 — Scale jobs

Scenario. ShopNow's monthly invoicing job processed 10 million orders on one node and took nine hours, close to the time window available.

Walkthrough. Spring Batch supports partitioned steps: a manager step splits the data into ranges, such as by order ID, and worker steps process each range in parallel, either in threads or on separate pods. Each partition commits its own chunks and can be restarted independently if it fails.

JAVA
@Bean
Step invoiceManagerStep(JobRepository repo, Step invoiceWorkerStep) {
    return new StepBuilder("invoiceManager", repo)
        .partitioner("invoiceWorker", new OrderIdRangePartitioner())
        .step(invoiceWorkerStep)
        .gridSize(8)
        .build();
}

Result. With eight partitions the job finished in about 75 minutes, and a failed partition could be restarted without reprocessing the others.

Takeaway. Batch jobs can scale horizontally too. Partition the data so workers do not contend with each other, and keep each partition restartable.

6.18 Worked example — metrics

Throughput per pod stable as N grows?Linear scaling check
Table 24 — Monitor efficiency

Scenario. ShopNow added pods during each traffic increase, but the bill grew faster than the traffic, and nobody could explain why.

Walkthrough. The team started tracking throughput per pod as the number of pods changed. In a linearly scaling system, throughput per pod stays roughly constant. Their dashboard showed it falling as pods were added, a sign of contention in shared resources, which they traced to an undersized connection pool on the database proxy.

Result. After fixing the proxy, throughput per pod stayed stable, and the number of pods needed at peak fell by a third.

Takeaway. Monitor scaling efficiency, not just total throughput. Falling throughput per node is an early warning that adding nodes is wasting money.

6.19 Worked example — ADR

DecisionRationale
Scale out services; scale up + replicas for AuroraStateless vs stateful
Table 25 — Recorded

Scenario. New engineers kept proposing sharding PostgreSQL, while others wanted to scale the database like the stateless services. The architecture group needed one documented position.

Walkthrough. An ADR recorded the decision: scale stateless services horizontally; scale the Aurora database vertically, with read replicas for reads and caching, before considering partitioning. The rationale is the difference between stateless and stateful components: horizontal scaling of databases requires partitioning, which is costly and constrains queries.

Result. Debates ended, and the ADR now defines when partitioning would be justified: sustained writer saturation after caching and vertical scaling are exhausted.

Takeaway. Record scaling strategy per component type in an ADR, including the conditions for changing it.

6.20 Worked example — review checklist

Check✔
Stateless app tier✔
DB scaling plan✔
Scaling curve measured✔
Quotas checked✔
Table 26 — Scalability review

Scenario. ShopNow reviews every new service's scalability with a short checklist before launch.

How to use it. Each item addresses a common scaling failure. The application tier is stateless, so pods can be added freely. There is a plan for scaling the database, such as replicas, caching or partitioning. The scaling curve has been measured with load tests. Cloud quotas have been checked against expected peak capacity. A missing tick becomes a launch blocker or a recorded risk.

Effect. Services launched after the checklist was introduced have not hit unexpected scaling limits during sales.

Takeaway. A short scalability checklist turns lessons from past incidents into routine practice.

6.21 Worked example — interview answer

DimensionAnswer
VerticalBigger node, simple, ceiling, SPOF
HorizontalMore nodes, linear, needs statelessness
Table 27 — Structured answer

Scenario. In interviews, ShopNow asks candidates to compare vertical and horizontal scaling.

How to answer. A clear answer contrasts the two on simplicity, limits and requirements. Vertical scaling means a bigger node: simple, no code changes, but with a hardware ceiling, rising cost at the top and a single point of failure. Horizontal scaling means more nodes: capacity grows roughly linearly and failures are partial, but it requires stateless services or partitioned data and load balancing.

How to finish. Adding when each fits, such as horizontal for stateless services and vertical plus replicas for databases, and mentioning Amdahl's Law shows depth.

Takeaway. Compare both approaches on the same criteria and finish with when to use each.

7Common Problems & Mistakes

  • Scaling the app while the database is the bottleneck.
  • Stateful instances blocking scale-out.
  • Global locks/sequences creating serial fractions.
  • Hot keys defeating partitioning.
  • Ignoring quotas and warm-up.
  • Assuming linear scaling without measuring.

8Performance & Production Considerations

AspectGuideline
App tierHorizontal, spread across AZs
Data tierVertical first, replicas, then partition
MeasurementScaling curves per tier
ContentionRemove serial sections
LimitsQuotas, partitions, connections
Table 28 — Operational guidelines

9Architecture & Design Considerations

  • Decide scaling strategy per tier.
  • Design for statelessness and partitionable data early.
  • Use the scale cube to reason about options.
  • Measure scalability, don't assume it.

10Interview Questions & Answers

Q1L1 · BasicConcept

What is scalability?

Scalability is the ability of a system to handle increased load, more users, requests or data, by adding resources, while keeping performance within acceptable limits. A scalable system's throughput grows roughly in proportion to the resources added, and its latency stays stable. Scalability is different from performance: a fast system may not scale, and a scalable system may be slow at low load. It is measured with load tests that increase both traffic and resources. Architectural choices such as statelessness, partitioning and avoiding shared bottlenecks largely determine how well a system scales.

Q2L1 · BasicConcept

What is vertical scaling?

Vertical scaling, or scaling up, means making a single node more powerful: more CPU cores, more memory, faster disks or network. It requires no changes to application design, because the system still runs on one node, and it keeps transactions and data local, which is why it is common for databases. Its limits are the largest available machine, rapidly rising cost at the top end, and the fact that the node remains a single point of failure. In containers, it also means giving a pod more resources and making sure the application, such as the JVM, can use them.

Q3L2 · IntermediateConcept

What does horizontal scaling require?

Horizontal scaling means adding more nodes that share the load. For that to work, any node must be able to handle any request, so services must be stateless: user sessions are stored externally, in a cache or tokens, and nodes keep no local state that matters. Stateful components need their data partitioned across nodes, with a partition key that spreads load evenly. A load balancer or partition-aware client distributes requests. Supporting infrastructure must also scale, such as database connections, caches and message partitions, and cloud quotas must allow the additional capacity.

Q4L2 · IntermediateConcept

Why is vertical scaling limited?

Vertical scaling hits several limits. Hardware has a ceiling: there is a largest instance size, and some workloads exceed it. Cost rises faster than capacity at the top end, so the biggest machines are expensive per unit of capacity. The node remains a single point of failure, so availability depends on one machine, and upgrades often require downtime. Software may also fail to use very large machines efficiently because of lock contention or garbage collection. For these reasons, vertical scaling is usually combined with replicas or eventually replaced by horizontal scaling.

Q5L3 · Senior EngineerConcept

What does Amdahl's Law say?

Amdahl's Law states that the speed-up from parallelising work is limited by the fraction that must run serially. If a fraction s of the work is serial, the maximum speed-up is 1 / s, however many processors are added. For example, with 5% serial work, the best possible speed-up is 20 times. In practice this means that reducing serial parts, such as global locks, single-threaded steps or coordination, often matters more than adding hardware. It also explains why scaling gives diminishing returns as nodes are added.

Q6L3 · Senior EngineerConcept

What does the USL add?

The Universal Scalability Law, proposed by Neil Gunther, adds a second cost to Amdahl's Law. Besides contention for shared resources, represented by σ, it models coherency, κ: the cost of nodes coordinating with each other, such as cache invalidation, distributed locks or cluster state updates. Because coherency cost grows with the number of node pairs, throughput can peak and then decline as more nodes are added. Fitting σ and κ from load-test measurements shows where the peak lies and whether to reduce contention or coordination before scaling further.

Q7L4 · Technical ArchitectScenario

How would you scale a PostgreSQL-backed service?

Scale the stateless application tier horizontally with more pods, making sure connection pools are sized so the total fits the database's connection limit, possibly with a pooler such as PgBouncer. Scale the database vertically first, choosing a larger instance as needed. Offload reads with read replicas, routing read-only transactions to them while accepting slight replication lag. Add caching for frequently read, rarely changing data. Optimise queries and indexes. Only if the writer remains saturated after these steps, consider partitioning or sharding, which is powerful but adds significant complexity.

Q8L5 · Solution ArchitectConcept

How do you explain the scale cube to stakeholders?

The scale cube describes three ways to scale. The x-axis is cloning: run more identical copies behind a load balancer, which increases capacity simply. The y-axis is functional decomposition: split the system by function into separate services, so teams and features can scale and change independently. The z-axis is data partitioning: split data by a key, such as customer or region, so each partition handles a subset, which increases capacity for large data sets and limits the impact of failures. Most large systems combine all three, choosing each where its benefits justify its cost.

Test your knowledge on this topic →Flashcards from this topic's 8 questions, filtered by level and type.

Free question pack

Get 100 free Core Java interview questions

Subscribe for the Book 1 question pack (PDF, every answer explained) and new tutorials once a week. No spam, unsubscribe anytime. What is in the pack?

Almost done! Check your inbox and click the confirmation link. Your download link arrives as soon as you confirm.