Overview

5 Build performance into your architecture

```html

This chapter argues that performance is largely an architectural outcome, not something that code tweaks can fix after the fact. It begins by separating speed, scalability, and resilience so teams can diagnose the real problem instead of applying the wrong solution. Speed is about how quickly one user completes one task, scalability is about how performance changes under load, and resilience is about how gracefully the system behaves when parts fail.

The main theme is to design rendering, initialization, and backend systems so users wait as little as possible on the critical path. For the web, that means choosing between all-at-once and progressive approaches such as server-side rendering, streaming, and selective hydration, based on the need for immediate content, interactivity, SEO, and device conditions. The same logic applies to mobile and desktop: initialize only what must run at startup, move everything else off the main thread or behind lazy loading, and choose between native, cross-platform, or hybrid architectures based on the app’s performance sensitivity, resource constraints, and team capabilities.

The chapter then extends the idea of performance-aware architecture to backends and data layers. It explains when monoliths outperform microservices, when edge computing or CDNs reduce latency, how API choices like REST, GraphQL, and gRPC shape round trips and payload cost, and why queues help by pushing non-critical work off the user’s critical path. It also covers database choices such as relational systems, NoSQL, replicas, connection pooling, and indexing, then closes with practical guidance for improving inherited systems through caching, facades, BFFs, async boundaries, and strangler-style migrations rather than risky rewrites unless the architecture is truly blocking progress.

```
Server-Side Rendering (SSR)
Client-Side Rendering (CSR)
Streaming SSR
Islands Architecture
The web rendering timeline
Monolith vs microservices latency
CDN latency advantage
Architectural improvement decision tree. If you can improve one piece without touching others, prefer incremental changes like caching or query optimization, which are lower risk and deliver quick wins. If every change forces coordinated modifications across the system, larger architectural changes become necessary despite longer timelines and coexistence costs.

Summary

  • Architecture determines the performance ceiling for everything that follows. The goal is not the theoretically fastest system but one where achieving acceptable performance is straightforward and does not require heroic effort.
  • Different platforms have different optimal patterns. Web applications choose between server, client, or hybrid rendering. Mobile apps optimize for battery and startup time. Desktop applications must remain responsive during extended sessions. Backend services balance monolith simplicity against microservice flexibility.
  • API design affects every request. REST offers simplicity and natural HTTP caching, GraphQL provides client flexibility at the cost of server complexity, and gRPC delivers maximum efficiency for internal services. Backend for Frontend patterns let you tailor responses to specific clients without building one API that tries to serve all platforms.
  • Edge computing and CDN strategies move logic and content closer to users. Operations needing only request data or cached content can run at the edge, while database operations require the origin.
  • Database architecture shapes query performance. Read replicas scale reads, connection pooling eliminates per-request overhead, proper indexing prevents table scans, and data fetching patterns like parallel requests and prefetching reduce critical path latency.
  • Message queues decouple critical path work from background processing, letting users see fast responses while workers handle emails, analytics, and downstream synchronization asynchronously.

FAQ

What is the main idea behind building performance into architecture?Performance starts with architecture, not just code-level optimization. If the system is designed in a way that forces users to wait on many sequential calls, heavy initialization, or unnecessary blocking, no amount of micro-optimization can fully fix it.
How are speed, scalability, and resilience different?Speed is how fast one user can complete a task under normal conditions. Scalability is how performance changes as traffic or data volume increases. Resilience is how well the system maintains acceptable performance when parts of it fail or degrade.
Why can’t frontend optimization fix a slow architecture?If the page depends on multiple sequential backend calls before anything can render, frontend improvements like bundle splitting or rendering tweaks can only help so much. The critical path is still blocked by backend latency, so the architecture itself sets the ceiling for performance.
When should you choose server-side rendering over client-side rendering?Choose server-side rendering when users need to see content immediately, search engines need to index the page, or initial time-to-content matters more than rich client-side interactivity. Client-side rendering fits better when authentication is required before meaningful content can be shown.
What problem do progressive rendering approaches solve?Progressive approaches reduce blocking by delivering content in pieces instead of waiting for everything to be ready. Streaming SSR helps on the server side, while Islands architecture reduces client-side hydration work by activating only the interactive parts of a page.
When is native mobile development worth the extra cost?Native development is worth it when performance is a competitive advantage, when the app must run well on low-end devices, or when deep platform integration is required. It gives the most control over startup time, initialization, memory use, and battery consumption.
Why do cross-platform mobile frameworks sometimes struggle with performance?They reduce development effort, but can introduce overhead through bridges, abstraction layers, or less direct access to platform-specific optimizations. They work best for moderate UI complexity, but can be weaker for demanding animations, real-time interactions, or startup performance.
When should a team consider microservices instead of a monolith?Microservices make sense when different parts of the system need independent scaling, when many teams need to deploy separately, or when fault isolation is important. For smaller teams or systems with uniform scaling needs, a well-structured monolith is often faster and simpler.
How do message queues improve performance?Message queues move non-critical work off the user’s critical path. They let the system respond quickly while background workers handle tasks like emails, analytics, indexing, or report generation later.
How can inherited architectures be improved without a risky rewrite?Start with incremental changes such as caching, facades, Backend for Frontend layers, connection pooling, replicas, or asynchronous processing. If every improvement requires coordinated changes across the whole system, then a larger rearchitecture may be justified.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Fast by Default ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Fast by Default ebook for free