[00:01] System design is all about making the right trade-offs. In our previous video, we covered data management trade-offs. Today, we'll explore another set of system design trade-offs that help us build better systems. [00:13] When an application needs to scale, we face the first significant trade-off. Vertical scaling involves adding more resources to existing servers, increasing CPU, or upgrading hardware. This approach requires no code changes, but eventually, [00:27] its physical limitations and requires expensive upgrades. Horizontal scaling means adding more servers to distribute the load. This provides virtually unlimited scaling potential and improved fault tolerance. [00:41] However, introduces complexity with load balancing, data consistency, and distributor system challenges. The fundamental trade-off is between simplicity and scalability. Vertical scaling is easier to manage but has a ceiling, [00:55] while horizontal provides more growth but requires more engineering effort. When designing APIs, most systems naturally start with REST APIs. They are mature, widely understood, and follow HTTP semantics [01:10] with clear resource-oriented patterns. As applications evolve, REST starts to show limitations. Frontend teams make multiple round trips to gather related data, endpoints for livery for specific UI needs, [01:23] and clients often receive more data than they need. GraphQL was developed to address these scaling pain points It enables clients to request precisely the data they need in a single query This flexibility introduces new challenges More complex server implementation [01:40] potential performance issues with nested queries, and security concerns with unbound queries. The key consideration isn't about which approach is better, but about understanding the application's maturity and requirements. REST extends for straightforward, quiet operations and proper [01:56] APIs, while GraphQL shines for complex UIs and diverse data requirements, and when front-end teams need more autonomy from back-end development cycles. Are you tired of juggling multiple AI tools and subscriptions? [02:11] Say hello to JetLLM Teams, the only all-in-one AI assistant that combines top models, creative tools, and developer features. Get access to top models like O3 Mini, GPT 4.1, Cloud Sonnet 3.7, Lama 3, and more. [02:28] When you ask any query, Raw LLM picks the best AI tools for your task. Generate stunning images with tools like Flux, DALI, and generate videos with Clink 2.0 Runway. [02:40] Chat with PDFs, generate PowerPoints and docs with simple prompts, and humanize AI tasks to ditch detectors. developers, enjoy GitHub integration, free code LLM in VS code and vibe coding with app LLM, [02:55] write run code and build chatbots with AI agents super easily All these for just a month way cheaper than separate subscriptions Click the link in the description and sign up now to access Chat LLM The Stateful vs Stateless trade has practical implications for specific application types [03:14] While most web services benefit from stateless design for scalability, certain applications fundamentally require server-side state. Game server needs to track player positions and game state. [03:26] WebSocket servers maintain persistent connections for chat applications. Trading platforms must track session state for transactions. In these cases, stateful design isn't optional. It's necessary for core functionality. [03:40] Modern architecture often combines both approaches, implementing stainless services for general operations with specialized stateful components for real-time features. As the applications scale, caching becomes essential for performance, [03:54] but how we update that cache presents another key trade-off. Most systems start with breakthrough caching. When data isn't in the cache, the system fetches it from the database, stores it in the cache, and then returns it to the user. [04:08] This simple approach works well until data freshness becomes critical. When User A updates information and User B requests it moments later, User B might see outdated data from a stale cache. [04:20] For inventory systems, financial transactions, or reservation platforms, this inconsistency can cause serious problems. Write-through caching addresses this by updating both the cache and the database simultaneously. [04:33] It ensures data freshness at the cost of added write complexity Finally let examine how a system responds to user requests Most applications naturally start with synchronous processing [04:46] It's straightforward, predictable, and provides immediate feedback. The client makes a request, the server processes completely, and returns a response. What happens when operations become time-consuming? [04:59] Long-running tasks like radio processing, report generation, or batch email sending can keep users waiting, degrading the experience. This is where asynchronous processing becomes valuable. [05:11] Instead of making users wait, the system acknowledges the request immediately and processes it in the background, potentially notifying users when it completes. This improves user experience but introduces complexity. [05:23] complexity. We need message queues, status tracking, retry mechanisms, and error handling strategies. The trade-off is about balancing implementation complexity against user experience [05:35] needs. System typically evolves towards a hybrid approach, keeping quick operations synchronous while offloading resource-intensive tasks to asynchronous processing. System design is fundamentally a series of trade-offs. Understanding these key architectural decisions [05:52] will help us build more resilient and efficient systems. If you like our videos, you might like our System Design Newsletter as well. It covers topics and trends in large-scale system design. [06:04] Trusted by 1 million readers.