Engineering notes
How to Design Scalable Software Architecture
A practical architecture guide to workload models, data ownership, capacity limits and incremental growth—without introducing distributed complexity before it solves a measured problem.
Scalability is the ability to handle a growing workload while staying within explicit limits for latency, correctness, availability and cost. It is not a property granted by a particular framework or deployment diagram. A system can run on many machines and still fail at one database lock. This guide develops an architecture from a hypothetical order-management product; all numbers are illustrative design inputs, not Bitcave benchmarks.
Start with a workload and a service objective
Describe the operations that matter: creating an order, listing recent orders, reserving stock and producing exports. Record their peak arrival rates, payload sizes, read/write ratios and acceptable freshness. Average traffic hides the burst that determines whether the checkout path remains usable. Separate interactive work from batch work because their latency budgets and failure tolerance differ.
Turn “fast” into a testable target. For example, a team might propose a p95 response-time target for order creation at a stated arrival rate and error threshold. That target needs product approval and a representative test before becoming a commitment. Also define what counts as failure: a fast HTTP response that silently loses an order is not success.
Conceptual illustration of the topic; not an implementation diagram.
Choose boundaries around rules and data ownership
A modular monolith is a useful starting design when one team owns the product and transactions frequently cross domain areas. Separate ordering, inventory and reporting through explicit interfaces. A boundary is meaningful when callers cannot bypass it to mutate another module’s tables, even if all modules initially share one database and deployment.
Identify invariants before distributing writes. “Reserved units cannot exceed available stock” needs an atomic enforcement mechanism such as a guarded update or a correctly scoped lock and transaction. A cache or asynchronous notification cannot enforce that invariant by itself. Treat reports and search projections as separate views with an explicit freshness policy.
Build a capacity budget across the whole request path
Map the path from edge to application, connection pool and database. Estimate concurrency using arrival rate multiplied by mean time in the system under stable conditions. At an illustrative 200 requests per second and 0.15-second mean response time, about 30 requests are in flight on average. This is a planning estimate; burstiness and tail latency still require load testing.
Budget shared resources across replicas. Four application instances with a maximum pool of 20 connections can request 80 database connections before background workers and operational sessions are counted. Adding instances can therefore make the database less stable. Reserve headroom, measure pool wait time and reject excess work deliberately rather than allowing unbounded waiting.
Give each scaling mechanism a specific job
Replicate stateless request handlers when application CPU or concurrency is the limiting resource. Store durable state outside individual instances and define how sessions and uploads survive replacement. Add indexes after inspecting query plans; use pagination that matches a stable ordering and the consistency needs of the interface.
Cache expensive reusable reads only after defining keys, expiry and invalidation. Include tenant and authorization context when results differ by caller. Move exports to a durable queue when users can accept deferred completion. A queue absorbs temporary bursts; it does not create processing capacity. Track oldest-job age and recovery time, not only queue length.
Evolve through measured decision gates
Suppose export jobs consume database capacity needed for checkout. First limit export concurrency, improve the query and consider a reporting projection. Extracting a reporting service may become useful when it needs independent deployment or resource isolation. It is not automatically useful merely because the codebase is large.
Write an architecture decision record containing the constraint, alternatives, selected option, failure model and reversal plan. A service extraction also requires ownership of its data, contract compatibility, migration, observability and incident response. Plan how old and new code coexist during rollout; an architecture that only works after a coordinated cutover has a deployment risk.
Validate failure and cost, then revisit the design
Test representative data size and distribution, realistic arrival patterns, a slow dependency, a failed instance and post-failure recovery. Track successful throughput, p95/p99 latency, error rate, database waits, connection saturation and resource cost. Ensure the load generator is not hiding overload by reducing traffic whenever responses slow down.
Common mistakes include sharding before fixing an inefficient query, sharing a writable database across supposedly independent services, treating autoscaling as a database remedy and using a stale cache for correctness decisions. The practical sequence is to state the workload, protect invariants, locate the limiting resource, change one relevant mechanism and test again. Simplicity remains valuable as long as it meets the measured requirements.
References and further reading
Django: database access optimization
Related content
Backend Development, APIs and System Design
Backend systems, databases and APIs that connect your interfaces, apply business rules and keep information moving between the tools your team uses.
Software Modernisation and Performance Optimisation
Architecture review, database tuning and focused software improvements for applications that have become slow, fragile or difficult to change.
Scalable System Design: Where Should a Growing Business Start?
Learn how to define growth requirements, find bottlenecks and choose between modules, queues, caching and separate services without losing sight of everyday operations.
Apply these decisions to your product
Describe the workload, current constraint and product goal to define the scope of a technical discussion.
Discuss your project
