5 Build performance into your architecture
This chapter covers
- Distinguishing speed, scalability, and resilience as separate architectural concerns
- Choosing rendering and initialization patterns for web, mobile, and desktop
- Selecting backend architectures: services, APIs, edge computing, and databases
- Designing database layers for performance at scale
- Using message queues for background processing
- Improving inherited architectures without risky rewrites
No amount of code-level optimization can overcome an underlying architecture that is inherently slow. On a recent web project, we spent three months optimizing JavaScript bundle sizes, code splitting strategies, and rendering performance, yet users still waited 4-5s before seeing content. The problem was not the frontend at all; the underlying architecture required seven sequential API calls to different backend services before the page could render anything. Pricing, inventory, promotions, customer preferences, financing options, stock locations, product configurations: each came from a separate legacy system, each adding up to 400ms of latency.
If your initial page load requires seven sequential round trips to different services, clever JavaScript optimization will not make it fast. If your mobile app initializes a dozen SDKs on startup, threading will not fix the fundamental problem. The architecture you choose sets the performance ceiling for your application.