VibeKoding / Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat / Principles of Web FrameworksPrinciples of Web Frameworks
VK

Principles of Web FrameworksPrinciples of Web Frameworks

๐Ÿ“š Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat ๐ŸŒ Dual Bahasa (ID / EN) โšก VibeKoding Native

Ensiklopedia VibeKoding: Principles of Web Frameworks.Ensiklopedia VibeKoding: Principles of Web Frameworks.

๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

You've written the code โ€” how do you make it accessible to people around the world? It's like asking: do you want to open a roadside food stall, or run a multinational restaurant chain? Your choice of backend architecture determines how many customers your "restaurant" can serve.You've written the code โ€” how do you make it accessible to people around the world? It's like asking: do you want to open a roadside food stall, or run a multinational restaurant chain? Your choice of backend architecture determines how many customers your "restaurant" can serve.

------

1. Motivation for Understanding Architectural Evolution1. Motivation for Understanding Architectural Evolution

Imagine you're planning a long-distance trip. You could choose to ride a bicycle, drive a car, take a high-speed train, or fly. Each mode of transport has its own sweet spot: a bicycle works for short distances when you want exercise; a plane is ideal for transcontinental journeys.Imagine you're planning a long-distance trip. You could choose to ride a bicycle, drive a car, take a high-speed train, or fly. Each mode of transport has its own sweet spot: a bicycle works for short distances when you want exercise; a plane is ideal for transcontinental journeys.

The same goes for backend architecture choices.The same goes for backend architecture choices.

From the birth of the internet to today, backend architecture has undergone several major transformations. Each transformation wasn't about "chasing the new" โ€” it was about solving specific problems at the time:From the birth of the internet to today, backend architecture has undergone several major transformations. Each transformation wasn't about "chasing the new" โ€” it was about solving specific problems at the time:

EraCore ProblemArchitectural Evolution
1990sHow to get a website runningPhysical servers
2000sCode is getting messy โ€” how to maintain itMonolithic architecture + MVC
2010sSystems are too large โ€” how to scale and collaborateMicroservices + containerization
2020sHow to reduce operational costs and complexityServerless + cloud-native
๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

Let's interpret it row by row: 1990s โ†’ 2000s: From "just get it running" to "it needs to be maintainable." Websites evolved from static pages to dynamic applications, and code volume exploded โ€” better organization was needed. 2000s โ†’ 2010s: From "single machine" to "distributed." User numbers grew exponentially; a single server couldn't handle the load anymore. Systems needed to be split and scaled horizontally. 2010s โ†’ 2020s: From "self-managed operations" to "cloud services." Containers and microservices, while powerful, came with high operational costs. Serverless lets developers focus solely on business logic. Core insight: Architectural evolution isn't a game of technology selection โ€” it's a process of solving real problems. Every stage has its applicable scenarios. There is no "best architecture," only the "most suitable architecture."Let's interpret it row by row: 1990s โ†’ 2000s: From "just get it running" to "it needs to be maintainable." Websites evolved from static pages to dynamic applications, and code volume exploded โ€” better organization was needed. 2000s โ†’ 2010s: From "single machine" to "distributed." User numbers grew exponentially; a single server couldn't handle the load anymore. Systems needed to be split and scaled horizontally. 2010s โ†’ 2020s: From "self-managed operations" to "cloud services." Containers and microservices, while powerful, came with high operational costs. Serverless lets developers focus solely on business logic. Core insight: Architectural evolution isn't a game of technology selection โ€” it's a process of solving real problems. Every stage has its applicable scenarios. There is no "best architecture," only the "most suitable architecture."

The value of understanding architectural evolution:The value of understanding architectural evolution:

  1. Avoid reinventing the wheel: Many "new" concepts had prototypes decades ago. Understanding history lets you stand on the shoulders of giants.Avoid reinventing the wheel: Many "new" concepts had prototypes decades ago. Understanding history lets you stand on the shoulders of giants.
  2. Make sound technology choices: There is no best architecture, only the one best suited to your current stage.Make sound technology choices: There is no best architecture, only the one best suited to your current stage.
  3. Understand the trade-offs behind technology: Every architectural evolution involves balancing development efficiency, system performance, and operational complexity.Understand the trade-offs behind technology: Every architectural evolution involves balancing development efficiency, system performance, and operational complexity.
  4. Anticipate technology trends: History rhymes. Understanding past evolutionary patterns helps you grasp future directions.Anticipate technology trends: History rhymes. Understanding past evolutionary patterns helps you grasp future directions.
  5. ------

    2. The Physical Server Era (1990s)2. The Physical Server Era (1990s)

    2.1 Overview of a Physical Server2.1 Overview of a Physical Server

    When the internet was just getting started, the backend was simply a physical server (a real computer) sitting in a data center.When the internet was just getting started, the backend was simply a physical server (a real computer) sitting in a data center.

    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    A physical server is like your desktop computer at home, but it: - Runs 24/7 without shutting down - Sits in a dedicated data center (with air conditioning, UPS power, fire suppression systems) - Has faster network bandwidth (enterprise-grade fiber) - Has a fixed public IP address (accessible from anywhere in the world) It's like your home kitchen vs. a restaurant: your home kitchen cooks occasionally; a restaurant is a professional kitchen, open all day, with professional-grade equipment.A physical server is like your desktop computer at home, but it: - Runs 24/7 without shutting down - Sits in a dedicated data center (with air conditioning, UPS power, fire suppression systems) - Has faster network bandwidth (enterprise-grade fiber) - Has a fixed public IP address (accessible from anywhere in the world) It's like your home kitchen vs. a restaurant: your home kitchen cooks occasionally; a restaurant is a professional kitchen, open all day, with professional-grade equipment.

    2.2 Core Characteristics2.2 Core Characteristics

    • Single-machine deployment: All applications run on one physical machineSingle-machine deployment: All applications run on one physical machine
    • Manual operations: Requires manual racking, cabling, and system installationManual operations: Requires manual racking, cabling, and system installation
    • Vertical scaling: When performance is insufficient, the only option is to buy a more powerful machineVertical scaling: When performance is insufficient, the only option is to buy a more powerful machine
    ๐Ÿ“– Konsep Penting๐Ÿ“– Core Concept

    Vertical Scaling (Scale Up): Upgrading a single server's configuration (more CPU, more RAM, faster disks). Horizontal Scaling (Scale Out): Adding more servers and having them work together. Analogy: - Vertical scaling: Turning a small restaurant into a larger one with fancier decor, but still only one chef - Horizontal scaling: Opening a chain โ€” each location is modest, but there are 100 of them Pros and Cons: - Vertical scaling is simple but has a ceiling (top-tier servers are expensive and have limits) - Horizontal scaling is theoretically unlimited but requires solving data consistency challengesVertical Scaling (Scale Up): Upgrading a single server's configuration (more CPU, more RAM, faster disks). Horizontal Scaling (Scale Out): Adding more servers and having them work together. Analogy: - Vertical scaling: Turning a small restaurant into a larger one with fancier decor, but still only one chef - Horizontal scaling: Opening a chain โ€” each location is modest, but there are 100 of them Pros and Cons: - Vertical scaling is simple but has a ceiling (top-tier servers are expensive and have limits) - Horizontal scaling is theoretically unlimited but requires solving data consistency challenges

    2.3 Pain Points2.3 Pain Points

    • Slow: Every code change required manual upload and server restartSlow: Every code change required manual upload and server restart
    • Expensive: Scaling meant buying bigger machines (vertical scaling only)Expensive: Scaling meant buying bigger machines (vertical scaling only)
    • Hard to scale: One machine handles all requests; when the CPU is maxed out, everyone queues upHard to scale: One machine handles all requests; when the CPU is maxed out, everyone queues up

    2.4 Pros and Cons of the Physical Server Era2.4 Pros and Cons of the Physical Server Era

    DimensionAssessment
    ProsFull hardware control, predictable performance; no virtualization overhead; physical data isolation, high security
    ConsLong procurement cycles (weeks); high upfront investment (CapEx); low resource utilization; difficult to scale
    Suitable forFinancial core systems, government classified systems, scenarios with strict data sovereignty requirements
    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    CapEx (Capital Expenditure): A large one-time investment to purchase hardware. OpEx (Operating Expenditure): Pay-as-you-go based on usage (e.g., cloud servers). Analogy: - CapEx: Buying a house โ€” pay a large lump sum upfront, then only monthly property fees - OpEx: Renting โ€” pay monthly rent, no huge upfront cost Cloud-era insight: Serverless and cloud services enable more companies to shift from CapEx to OpEx, lowering the barrier to starting a business.CapEx (Capital Expenditure): A large one-time investment to purchase hardware. OpEx (Operating Expenditure): Pay-as-you-go based on usage (e.g., cloud servers). Analogy: - CapEx: Buying a house โ€” pay a large lump sum upfront, then only monthly property fees - OpEx: Renting โ€” pay monthly rent, no huge upfront cost Cloud-era insight: Serverless and cloud services enable more companies to shift from CapEx to OpEx, lowering the barrier to starting a business.

    ------

    3. The Monolithic Architecture Era (2000s)3. The Monolithic Architecture Era (2000s)

    3.1 Overview of Monolithic Architecture3.1 Overview of Monolithic Architecture

    With the rise of frameworks (Rails / Django / Spring), everyone started packing all functionality into a single application.With the rise of frameworks (Rails / Django / Spring), everyone started packing all functionality into a single application.

    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    Monolithic architecture (Monolith) is like a super-mall: - Clothing, food, and electronics sections are all in the same building - All employees work within a single management system - If the whole building loses power, every section shuts down In contrast, microservices are like a commercial street: each shop operates independently; one shop closing doesn't affect the others.Monolithic architecture (Monolith) is like a super-mall: - Clothing, food, and electronics sections are all in the same building - All employees work within a single management system - If the whole building loses power, every section shuts down In contrast, microservices are like a commercial street: each shop operates independently; one shop closing doesn't affect the others.

    3.2 Core Characteristics3.2 Core Characteristics

    • Single codebase: All functional modules live in the same projectSingle codebase: All functional modules live in the same project
    • Shared database: All modules share the same databaseShared database: All modules share the same database
    • Unified deployment: The entire application is packaged and deployed as a wholeUnified deployment: The entire application is packaged and deployed as a whole

    3.3 Advantages3.3 Advantages

    • Simple to develop: One project handles all functionalitySimple to develop: One project handles all functionality
    • Easy to deploy: Just throw one big package onto the serverEasy to deploy: Just throw one big package onto the server
    • Easy to debug: Start it locally and you can debug everythingEasy to debug: Start it locally and you can debug everything

    3.4 Pain Point: The Avalanche Effect3.4 Pain Point: The Avalanche Effect

    Imagine the chef "chopping vegetables" accidentally cuts their hand (a bug in the code). The entire kitchen has to stop to treat the wound, and every customer goes hungry.Imagine the chef "chopping vegetables" accidentally cuts their hand (a bug in the code). The entire kitchen has to stop to treat the wound, and every customer goes hungry.

    This is the biggest risk of monolithic architecture: poor isolation.This is the biggest risk of monolithic architecture: poor isolation.

    ๐Ÿ“– Konsep Penting๐Ÿ“– Core Concept

    An e-commerce company during a Double 11 mega-sale: - The order service throws an exception due to a pricing calculation error on a specific item - The exception isn't properly caught, exhausting the thread pool - All subsequent requests (including product browsing, search, user login) get blocked - The entire website goes down completely for 1 hour If they had used microservices: - The order service would be down, but product browsing, search, and user login would still work - Users could at least continue browsing products, minimizing lossesAn e-commerce company during a Double 11 mega-sale: - The order service throws an exception due to a pricing calculation error on a specific item - The exception isn't properly caught, exhausting the thread pool - All subsequent requests (including product browsing, search, user login) get blocked - The entire website goes down completely for 1 hour If they had used microservices: - The order service would be down, but product browsing, search, and user login would still work - Users could at least continue browsing products, minimizing losses

    3.5 Pros, Cons, and Suitable Scenarios for Monolithic Architecture3.5 Pros, Cons, and Suitable Scenarios for Monolithic Architecture

    DimensionAssessment
    ProsSimple to develop, no distributed complexity to worry about; easy to debug โ€” start locally and debug everything; simple deployment โ€” one package runs it all; easy transaction management โ€” a single-machine database ensures ACID
    ConsHigh code coupling, codebase bloats as the business grows; single technology stack, hard to upgrade partially; difficult to scale โ€” can only scale the whole thing; poor fault isolation โ€” one module failure affects the entire system; low team collaboration efficiency โ€” many people editing the same codebase
    Suitable forStartup MVP validation, small teams (<10 people), relatively simple business, scenarios where delivery speed matters more than scalability
    Not suitable forLarge teams doing parallel development, scenarios requiring frequent independent module releases, scenarios where certain modules need independent scaling
    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    If you're learning backend development, I strongly recommend starting with monolithic architecture: 1. Learn to walk first: Understand HTTP, databases, and basic MVC architecture 2. Then consider running: When your project genuinely encounters scalability issues, then consider microservices 3. Avoid over-engineering: Many companies' "microservices" are actually "distributed monoliths" โ€” even harder to maintain Learning path: - Phase 1: Build a complete monolithic application with Spring Boot / Django / Rails - Phase 2: When you hit performance bottlenecks, try splitting out 1โ€“2 services - Phase 3: When the team exceeds 50 people and the system is genuinely complex, then go full microservicesIf you're learning backend development, I strongly recommend starting with monolithic architecture: 1. Learn to walk first: Understand HTTP, databases, and basic MVC architecture 2. Then consider running: When your project genuinely encounters scalability issues, then consider microservices 3. Avoid over-engineering: Many companies' "microservices" are actually "distributed monoliths" โ€” even harder to maintain Learning path: - Phase 1: Build a complete monolithic application with Spring Boot / Django / Rails - Phase 2: When you hit performance bottlenecks, try splitting out 1โ€“2 services - Phase 3: When the team exceeds 50 people and the system is genuinely complex, then go full microservices

    3.6 Technology Stack for Monolithic Architecture3.6 Technology Stack for Monolithic Architecture

    Language/FrameworkCharacteristicsRepresentative Companies
    Java + SpringEnterprise-grade development standard, mature ecosystemAlibaba, JD.com
    PHP + Laravel/ThinkPHPRapid development, suitable for small-to-medium projectsEarly Facebook, Weibo
    Python + Django/FlaskHigh development efficiency, great for rapid prototypingInstagram, Pinterest
    Ruby on RailsConvention over configuration, startup favoriteGitHub, Twitter (early days)
    Node.js + ExpressUnified language for frontend and backend, I/O-intensive scenariosNetflix, Uber

    ------

    4. Containerization and Microservices (2010s)4. Containerization and Microservices (2010s)

    4.1 Motivation for Microservicesing4.1 Motivation for Microservicesing

    The pain points of monolithic architecture erupted in the 2010s:The pain points of monolithic architecture erupted in the 2010s:

    • Code too massive: A project with millions of lines of code โ€” new hires need a month just to understand itCode too massive: A project with millions of lines of code โ€” new hires need a month just to understand it
    • Deployment too slow: A build takes 30 minutes; every release requires extreme cautionDeployment too slow: A build takes 30 minutes; every release requires extreme caution
    • Collaboration too hard: 100 developers editing the same project โ€” code conflicts happen dailyCollaboration too hard: 100 developers editing the same project โ€” code conflicts happen daily
    • Scaling too expensive: You only need to scale the "chat service," but you have to replicate the entire applicationScaling too expensive: You only need to scale the "chat service," but you have to replicate the entire application

    The core idea of microservices: Split the big application into many small services, each:The core idea of microservices: Split the big application into many small services, each:

    • Independently developed and deployedIndependently developed and deployed
    • With its own databaseWith its own database
    • Communicating via APIsCommunicating via APIs

    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    Docker is like a "shipping container": - Each container holds independent cargo (code + dependencies + runtime environment) - No matter where it's shipped (which server), you open the container and it's ready to work - No more worrying about "this machine doesn't have Python 3.9" or "that machine is missing a library" Analogy: - Without Docker: Every time you move, you have to carry furniture, appliances, and clothes piece by piece onto the truck, then arrange them one by one at the new place - With Docker: Everything is packed into a container; the truck moves it directly; at the new place, you drop it and it's ready to use Core value: "Build once, run anywhere."Docker is like a "shipping container": - Each container holds independent cargo (code + dependencies + runtime environment) - No matter where it's shipped (which server), you open the container and it's ready to work - No more worrying about "this machine doesn't have Python 3.9" or "that machine is missing a library" Analogy: - Without Docker: Every time you move, you have to carry furniture, appliances, and clothes piece by piece onto the truck, then arrange them one by one at the new place - With Docker: Everything is packed into a container; the truck moves it directly; at the new place, you drop it and it's ready to use Core value: "Build once, run anywhere."

    4.2 Technology Stack Timeline4.2 Technology Stack Timeline

    4.3 Microservices Architecture4.3 Microservices Architecture

    To solve the monolith's problems, we split the big kitchen into many small kitchens (services):To solve the monolith's problems, we split the big kitchen into many small kitchens (services):

    • A service dedicated to usersA service dedicated to users
    • A service dedicated to ordersA service dedicated to orders
    • A service dedicated to paymentsA service dedicated to payments

    4.4 Kubernetes Orchestration4.4 Kubernetes Orchestration

    When the number of containers reaches hundreds or thousands, you need a "port dispatching system":When the number of containers reaches hundreds or thousands, you need a "port dispatching system":

    • Kubernetes (K8s): Responsible for scheduling containers onto appropriate machines (scheduling, scaling, rolling updates)Kubernetes (K8s): Responsible for scheduling containers onto appropriate machines (scheduling, scaling, rolling updates)
    • Service Mesh: Responsible for traffic rules between services (circuit breaking, rate limiting, retries, observability)Service Mesh: Responsible for traffic rules between services (circuit breaking, rate limiting, retries, observability)

    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    Orchestration refers to a system that automatically manages large numbers of containers. Analogy: - Without K8s: You manually manage 100 containers โ€” restart the ones that crash, add machines manually when traffic spikes - With K8s: You tell it "I want this service to always have 10 instances running," and it automatically: - Schedules containers to servers with sufficient resources - Auto-restarts containers that crash - Auto-scales to 20 instances when traffic spikes - Performs rolling updates when deploying new code (stop one old instance, start one new instance, replace one by one) Key point: Microservices aren't just about "splitting things up." The real challenge lies in governance and operations.Orchestration refers to a system that automatically manages large numbers of containers. Analogy: - Without K8s: You manually manage 100 containers โ€” restart the ones that crash, add machines manually when traffic spikes - With K8s: You tell it "I want this service to always have 10 instances running," and it automatically: - Schedules containers to servers with sufficient resources - Auto-restarts containers that crash - Auto-scales to 20 instances when traffic spikes - Performs rolling updates when deploying new code (stop one old instance, start one new instance, replace one by one) Key point: Microservices aren't just about "splitting things up." The real challenge lies in governance and operations.

    4.5 Pros and Cons of Microservices and Containerization4.5 Pros and Cons of Microservices and Containerization

    DimensionAssessment
    ProsIndependent service deployment, heterogeneous technology stacks possible; fault isolation โ€” a single service crash doesn't affect the whole; on-demand scaling โ€” scale only hot services; team-friendly โ€” different teams own different services; smaller codebases, easier to understand and maintain
    ConsHigh distributed complexity (network latency, distributed transactions, service discovery); high operational cost, requires a professional DevOps team; difficult to debug โ€” issues may need tracing across multiple services; hard to guarantee data consistency; complex deployment and monitoring infrastructure requirements
    Suitable forLarge teams (>50 people), complex business requiring independent module evolution, certain modules needing independent scaling, multi-language tech stacks, systems with high availability requirements
    Not suitable forSmall teams, simple business, low and stable traffic, situations without a professional operations team
    ๐Ÿ“– Konsep Penting๐Ÿ“– Core Concept

    Pitfall 1: The Distributed Monolith You split into 10 microservices, but they're tightly coupled: - Service A calls Service B, Service B calls Service C, Service C calls Service A again - Changing one feature requires modifying 5 services simultaneously - Deployment must follow a strict sequence, or the system throws errors This is worse than a monolith: you have all the complexity of a monolith without enjoying the independent deployment benefits of microservices. Pitfall 2: Over-Splitting Splitting a 100-line feature into its own independent service: - 10 services, each with only 100 lines of code - The overhead of inter-service communication (network serialization/deserialization) outweighs the actual business logic - Operational costs explode: you need to deploy, monitor, and collect logs for 10 services The right approach: Split from the perspective of functional cohesion. A microservice should represent a complete business capability (e.g., "Order Service," not "Order Creation Service" and "Order Query Service").Pitfall 1: The Distributed Monolith You split into 10 microservices, but they're tightly coupled: - Service A calls Service B, Service B calls Service C, Service C calls Service A again - Changing one feature requires modifying 5 services simultaneously - Deployment must follow a strict sequence, or the system throws errors This is worse than a monolith: you have all the complexity of a monolith without enjoying the independent deployment benefits of microservices. Pitfall 2: Over-Splitting Splitting a 100-line feature into its own independent service: - 10 services, each with only 100 lines of code - The overhead of inter-service communication (network serialization/deserialization) outweighs the actual business logic - Operational costs explode: you need to deploy, monitor, and collect logs for 10 services The right approach: Split from the perspective of functional cohesion. A microservice should represent a complete business capability (e.g., "Order Service," not "Order Creation Service" and "Order Query Service").

    4.6 Microservices Technology Stack4.6 Microservices Technology Stack

    CategoryTechnology/ToolPurpose
    ContainerizationDocker, containerdApplication packaging and isolation
    OrchestrationKubernetes, Docker SwarmContainer management and auto-scaling
    Service DiscoveryConsul, etcd, ZooKeeperService registration and discovery
    API GatewayKong, Zuul, EnvoyUnified entry point, routing, rate limiting
    Config CenterApollo, Nacos, Spring Cloud ConfigCentralized configuration management
    Monitoring & AlertingPrometheus, Grafana, ELKMetrics monitoring and log analysis
    Distributed TracingJaeger, Zipkin, SkyWalkingDistributed request tracing
    Service MeshIstio, LinkerdTraffic governance and security

    ------

    5. The Serverless and Cloud-Native Era (2020s+)5. The Serverless and Cloud-Native Era (2020s+)

    5.1 Motivation for Serverlessing5.1 Motivation for Serverlessing

    Microservices are great, but maintaining dozens of small kitchens is still exhausting. You still need to worry about:Microservices are great, but maintaining dozens of small kitchens is still exhausting. You still need to worry about:

    • Is the kitchen big enough? (server scaling)Is the kitchen big enough? (server scaling)
    • What if the power goes out? (high availability)What if the power goes out? (high availability)
    • How to manage so many containers? (operational costs)How to manage so many containers? (operational costs)

    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    Serverless means "you don't need to manage servers," not that there are literally no servers. Analogy: - Physical server era: You buy the land, build the house, decorate, hire chefs, buy ingredients... everything yourself - Cloud server era: You rent an already-renovated restaurant, but you still hire chefs and manage operations - Serverless era: You only need to design the menu. The cloud has a shared kitchen with professional chefs. You place orders, they cook, and you pay per use The core change: - Before: Buy servers โ†’ configure environments โ†’ deploy code โ†’ monitor โ†’ scale โ†’ maintain - Now: Write code โ†’ upload โ†’ pay per usage It's like food delivery: you don't need a kitchen โ€” you just design the menu, and someone else does the cooking.Serverless means "you don't need to manage servers," not that there are literally no servers. Analogy: - Physical server era: You buy the land, build the house, decorate, hire chefs, buy ingredients... everything yourself - Cloud server era: You rent an already-renovated restaurant, but you still hire chefs and manage operations - Serverless era: You only need to design the menu. The cloud has a shared kitchen with professional chefs. You place orders, they cook, and you pay per use The core change: - Before: Buy servers โ†’ configure environments โ†’ deploy code โ†’ monitor โ†’ scale โ†’ maintain - Now: Write code โ†’ upload โ†’ pay per usage It's like food delivery: you don't need a kitchen โ€” you just design the menu, and someone else does the cooking.

    5.2 Overview of Serverless5.2 Overview of Serverless

    Serverless = FaaS + BaaSServerless = FaaS + BaaS

    FaaS (Function as a Service):FaaS (Function as a Service):

    • You only write functions (e.g., "send a welcome email when a user registers")You only write functions (e.g., "send a welcome email when a user registers")
    • The cloud provider runs the function and auto-scales itThe cloud provider runs the function and auto-scales it
    • Typical examples: AWS Lambda, Alibaba Cloud Function ComputeTypical examples: AWS Lambda, Alibaba Cloud Function Compute

    BaaS (Backend as a Service):BaaS (Backend as a Service):

    • Authentication โ†’ Auth0 / Supabase AuthAuthentication โ†’ Auth0 / Supabase Auth
    • Payments โ†’ StripePayments โ†’ Stripe
    • Database โ†’ Supabase / Firebase / DynamoDBDatabase โ†’ Supabase / Firebase / DynamoDB
    • Messaging โ†’ Kafka / SQSMessaging โ†’ Kafka / SQS
    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    Best scenarios: 1. Tidal traffic: Food delivery apps โ€” heavy traffic at noon, almost none at midnight. Serverless automatically allocates 1,000 machines at noon and scales down to 0 at midnight 2. Event-driven: "When a user uploads an image, automatically compress it" 3. Rapid validation: Small teams, MVPs, hackathon projects Unsuitable scenarios: 1. Long-running tasks: Video transcoding (may run for 1 hour, but function max execution time is typically 15 minutes) 2. Low-latency applications: High-frequency trading (cold start latency can range from tens of milliseconds to several seconds) 3. Fine-grained low-level control: OS kernel tuning, direct GPU accessBest scenarios: 1. Tidal traffic: Food delivery apps โ€” heavy traffic at noon, almost none at midnight. Serverless automatically allocates 1,000 machines at noon and scales down to 0 at midnight 2. Event-driven: "When a user uploads an image, automatically compress it" 3. Rapid validation: Small teams, MVPs, hackathon projects Unsuitable scenarios: 1. Long-running tasks: Video transcoding (may run for 1 hour, but function max execution time is typically 15 minutes) 2. Low-latency applications: High-frequency trading (cold start latency can range from tens of milliseconds to several seconds) 3. Fine-grained low-level control: OS kernel tuning, direct GPU access

    5.3 Pros and Cons of Serverless and Cloud-Native5.3 Pros and Cons of Serverless and Cloud-Native

    DimensionAssessment
    ProsZero operational cost โ€” developers only focus on business code; automatic scaling, perfectly handles traffic spikes; pay-per-use, near-zero cost when idle; rapid time-to-market, deploy globally in minutes; built-in high availability, cloud services handle failover automatically
    ConsCold start latency (hundreds of milliseconds to several seconds); runtime duration limits (typically 5โ€“15 minutes); difficult to debug โ€” hard to fully simulate the cloud environment locally; vendor lock-in risk; unsuitable for long-running or compute-intensive tasks; costs can exceed traditional approaches under sustained high traffic
    Suitable forEvent-driven processing (image processing, message notifications); tidal traffic applications (campaign pages, promotions); rapid prototyping and MVP validation; low-frequency APIs or background tasks; small teams without dedicated operations
    Not suitable forApplications requiring consistently low latency; long-running compute tasks; scenarios sensitive to cold starts (high-frequency trading); scenarios requiring fine-grained control over underlying infrastructure
    ๐Ÿ“– Konsep Penting๐Ÿ“– Core Concept

    Scenario 1: Low-frequency access - Traditional server: $20/month (regardless of traffic) - Serverless: 1 million requests ร— $0.0002/request = $20 (pay only when there's traffic) - Conclusion: For low-frequency scenarios, Serverless is cheaper Scenario 2: High-frequency sustained access - Traditional server: $20/month - Serverless: 100 million requests ร— $0.0002/request = $20,000 - Conclusion: For sustained high-frequency scenarios, traditional servers are cheaper Scenario 3: Tidal traffic - Traditional server: To handle peak traffic, you need a $100/month server (average resource utilization is only 10%) - Serverless: $20 during peaks, nearly $0 during off-peak - Conclusion: For tidal traffic scenarios, Serverless saves costs Takeaway: Don't blindly adopt Serverless. Run cost estimates based on your actual traffic patterns.Scenario 1: Low-frequency access - Traditional server: $20/month (regardless of traffic) - Serverless: 1 million requests ร— $0.0002/request = $20 (pay only when there's traffic) - Conclusion: For low-frequency scenarios, Serverless is cheaper Scenario 2: High-frequency sustained access - Traditional server: $20/month - Serverless: 100 million requests ร— $0.0002/request = $20,000 - Conclusion: For sustained high-frequency scenarios, traditional servers are cheaper Scenario 3: Tidal traffic - Traditional server: To handle peak traffic, you need a $100/month server (average resource utilization is only 10%) - Serverless: $20 during peaks, nearly $0 during off-peak - Conclusion: For tidal traffic scenarios, Serverless saves costs Takeaway: Don't blindly adopt Serverless. Run cost estimates based on your actual traffic patterns.

    5.4 Serverless Technology Stack and Platforms5.4 Serverless Technology Stack and Platforms

    CategoryTechnology/PlatformCharacteristics
    FaaS PlatformsAWS LambdaThe earliest FaaS service, most mature ecosystem
    Azure FunctionsDeep Microsoft cloud integration, .NET-friendly
    Google Cloud FunctionsDeep integration with GCP services
    Alibaba Cloud Function ComputeMature domestic ecosystem, good cold-start optimization
    Tencent Cloud SCFIntegrated with WeChat ecosystem
    Vercel/Netlify FunctionsFrontend-developer-friendly, edge deployment
    BaaS ServicesFirebaseGoogle's mobile backend solution
    SupabaseOpen-source Firebase alternative for PostgreSQL
    AWS AmplifyAWS development platform for mobile and web apps
    Deployment ToolsServerless FrameworkMulti-cloud deployment, active community
    TerraformInfrastructure as Code
    PulumiDefine infrastructure using programming languages

    ------

    6. Architecture Comparison and Selection Guide6. Architecture Comparison and Selection Guide

    6.1 Full Architecture Evolution Comparison6.1 Full Architecture Evolution Comparison

    DimensionPhysical ServersMonolithic ArchitectureMicroservices + ContainersServerless
    Team Size1โ€“5 people5โ€“50 people50โ€“500 people1โ€“20 people
    Deployment ComplexityExtremely highLowExtremely highExtremely low
    Operational CostHighMediumVery highLow
    ScalabilityPoorLimited vertical scalingExcellent horizontal scalingAuto-scaling
    Tech Stack FlexibilityNoneSingleDiverseLimited
    Cold StartNoneNoneContainer startup timeHas latency
    Suitable forLegacy systems, special compliance requirementsStartups, simple businessLarge internet companies, complex businessRapid validation, event-driven

    6.2 Technology Selection Decision Tree6.2 Technology Selection Decision Tree

    CODE
    Start Selection โ”‚ โ”œโ”€ Does the team have professional ops personnel? โ”‚ โ”œโ”€ Yes โ†’ Consider microservices or physical machines โ”‚ โ””โ”€ No โ†’ Continue evaluating โ”‚ โ”œโ”€ Need to launch quickly to validate an idea? โ”‚ โ”œโ”€ Yes โ†’ Serverless or monolith โ”‚ โ””โ”€ No โ†’ Continue evaluating โ”‚ โ”œโ”€ Team size > 50 people? โ”‚ โ”œโ”€ Yes โ†’ Consider microservices โ”‚ โ””โ”€ No โ†’ Continue evaluating โ”‚ โ”œโ”€ Does traffic have clear peak/off-peak patterns? โ”‚ โ”œโ”€ Yes โ†’ Serverless โ”‚ โ””โ”€ No โ†’ Monolithic architecture (recommended for startups) โ”‚ โ””โ”€ Special requirements (compliance, legacy systems)? โ””โ”€ Yes โ†’ Physical servers
    
    ๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

    If you're an individual developer or a small team: 1. Phase 0 (Learning): Run a monolithic app locally; understand HTTP, databases, and basic architecture 2. Phase 1 (MVP): Deploy the monolithic app to a cloud server (e.g., Alibaba Cloud ECS, AWS EC2) 3. Phase 2 (Growth): When the team exceeds 10 people and the business becomes complex, consider splitting out 1โ€“2 microservices 4. Phase 3 (Maturity): When the team exceeds 50 people and traffic reaches millions, go full microservices Key principle: Don't start with microservices โ€” that's "premature optimization." Let the architecture evolve as the business grows.If you're an individual developer or a small team: 1. Phase 0 (Learning): Run a monolithic app locally; understand HTTP, databases, and basic architecture 2. Phase 1 (MVP): Deploy the monolithic app to a cloud server (e.g., Alibaba Cloud ECS, AWS EC2) 3. Phase 2 (Growth): When the team exceeds 10 people and the business becomes complex, consider splitting out 1โ€“2 microservices 4. Phase 3 (Maturity): When the team exceeds 50 people and traffic reaches millions, go full microservices Key principle: Don't start with microservices โ€” that's "premature optimization." Let the architecture evolve as the business grows.

    6.3 Recommended Architecture for Different Scenarios6.3 Recommended Architecture for Different Scenarios

    Scenario 1: Solo Developer / Side ProjectScenario 1: Solo Developer / Side Project

    • Recommended architecture: Serverless (Vercel/Netlify) or monolithic applicationRecommended architecture: Serverless (Vercel/Netlify) or monolithic application
    • Rationale: Near-zero operational cost, pay-per-use, rapid time-to-marketRationale: Near-zero operational cost, pay-per-use, rapid time-to-market
    • Example tech stack: Next.js + Vercel + SupabaseExample tech stack: Next.js + Vercel + Supabase

    Scenario 2: Startup MVP ValidationScenario 2: Startup MVP Validation

    • Recommended architecture: Monolithic architecture + cloud serverRecommended architecture: Monolithic architecture + cloud server
    • Rationale: Fast development speed; the team can focus on business logic rather than infrastructureRationale: Fast development speed; the team can focus on business logic rather than infrastructure
    • Example tech stack: Spring Boot / Django / Rails + RDS + ECSExample tech stack: Spring Boot / Django / Rails + RDS + ECS

    Scenario 3: Growing Company (10โ€“50 person team)Scenario 3: Growing Company (10โ€“50 person team)

    • Recommended architecture: Modular monolith or lightweight microservicesRecommended architecture: Modular monolith or lightweight microservices
    • Rationale: Starting to face code coupling issues, but not yet needing full microservices complexityRationale: Starting to face code coupling issues, but not yet needing full microservices complexity
    • Example tech stack: Spring Cloud / Go Micro + KubernetesExample tech stack: Spring Cloud / Go Micro + Kubernetes

    Scenario 4: Large Internet CompanyScenario 4: Large Internet Company

    • Recommended architecture: Microservices + Service Mesh + middle-platform architectureRecommended architecture: Microservices + Service Mesh + middle-platform architecture
    • Rationale: Large team, complex business, need independent release cadences and technology stacksRationale: Large team, complex business, need independent release cadences and technology stacks
    • Example tech stack: In-house RPC framework + Istio + self-built PaaS platformExample tech stack: In-house RPC framework + Istio + self-built PaaS platform

    Scenario 5: Event-Driven / Tidal Traffic ApplicationsScenario 5: Event-Driven / Tidal Traffic Applications

    • Recommended architecture: Serverless + event busRecommended architecture: Serverless + event bus
    • Rationale: High traffic volatility, need extreme cost optimization and auto-scalingRationale: High traffic volatility, need extreme cost optimization and auto-scaling
    • Example tech stack: AWS Lambda + API Gateway + EventBridgeExample tech stack: AWS Lambda + API Gateway + EventBridge

    ------

    7. Summary and Learning Roadmap7. Summary and Learning Roadmap

    7.1 Key Takeaways7.1 Key Takeaways

    The evolution of backend architecture is fundamentally about addition and subtraction:The evolution of backend architecture is fundamentally about addition and subtraction:

    EraArchitectureWhat Developers DoWhat Ops Do
    Physical EraSingle machineWrite scripts, deploy manuallyMaintain data centers and hardware
    Monolith EraOne big blockWrite all business logicMaintain a few large servers
    Microservices EraSplit upFocus on a single business domainMaintain K8s clusters (exhausting!)
    ServerlessFunctionsWrite only core functionsDrink tea (cloud provider handles everything)

    Key insights:Key insights:

    • Architectural evolution isn't "new technology replacing old technology" โ€” it's about changes in applicable scenariosArchitectural evolution isn't "new technology replacing old technology" โ€” it's about changes in applicable scenarios
    • There is no silver bullet; every architecture has its boundariesThere is no silver bullet; every architecture has its boundaries
    • When choosing an architecture, consider: team size, business complexity, traffic patterns, and operational capabilityWhen choosing an architecture, consider: team size, business complexity, traffic patterns, and operational capability

    7.2 Recommended Learning Roadmap7.2 Recommended Learning Roadmap

    Based on your career stage, here are the recommended learning paths:Based on your career stage, here are the recommended learning paths:

    Phase 1: Build the Foundation (0โ€“1 year)Phase 1: Build the Foundation (0โ€“1 year)

    Goal: Understand core backend concepts; be able to independently develop a monolithic applicationGoal: Understand core backend concepts; be able to independently develop a monolithic application

    • Master one backend language (choose from Java/Python/Go)Master one backend language (choose from Java/Python/Go)
    • Learn the HTTP protocol and RESTful API designLearn the HTTP protocol and RESTful API design
    • Master relational databases (MySQL/PostgreSQL)Master relational databases (MySQL/PostgreSQL)
    • Understand caching basics (Redis)Understand caching basics (Redis)
    • Learn Git and basic Linux commandsLearn Git and basic Linux commands
    • Practice project: Build a CRUD application with monolithic architecture (e.g., a blog system, a to-do app)Practice project: Build a CRUD application with monolithic architecture (e.g., a blog system, a to-do app)

    Phase 2: Expand Capabilities (1โ€“3 years)Phase 2: Expand Capabilities (1โ€“3 years)

    Goal: Understand distributed systems; be able to participate in microservices developmentGoal: Understand distributed systems; be able to participate in microservices development

    • Deep-dive into microservices architecture and splitting strategiesDeep-dive into microservices architecture and splitting strategies
    • Master Docker and Kubernetes basicsMaster Docker and Kubernetes basics
    • Learn message queues (Kafka/RabbitMQ)Learn message queues (Kafka/RabbitMQ)
    • Understand distributed transactions and consistencyUnderstand distributed transactions and consistency
    • Master monitoring and logging (Prometheus/ELK)Master monitoring and logging (Prometheus/ELK)
    • Practice project: Split a monolithic application into 3โ€“5 microservices and deploy with DockerPractice project: Split a monolithic application into 3โ€“5 microservices and deploy with Docker

    Phase 3: Professional Deepening (3โ€“5 years)Phase 3: Professional Deepening (3โ€“5 years)

    Goal: Be able to design large-scale systems; possess technology selection skillsGoal: Be able to design large-scale systems; possess technology selection skills

    • Deeply understand cloud-native architecture (Service Mesh, Serverless)Deeply understand cloud-native architecture (Service Mesh, Serverless)
    • Master capacity planning and performance tuningMaster capacity planning and performance tuning
    • Understand multi-active architecture and disaster recovery designUnderstand multi-active architecture and disaster recovery design
    • Learn DDD (Domain-Driven Design)Learn DDD (Domain-Driven Design)
    • Cultivate technical judgment and architectural thinkingCultivate technical judgment and architectural thinking
    • Practice project: Design a system architecture supporting millions of users, including high availability and elastic scaling solutionsPractice project: Design a system architecture supporting millions of users, including high availability and elastic scaling solutions

    7.3 Recommended Continuous Learning Resources7.3 Recommended Continuous Learning Resources

    Books:Books:

    • Designing Data-Intensive Applications (DDIA) โ€” essential reading for distributed systemsDesigning Data-Intensive Applications (DDIA) โ€” essential reading for distributed systems
    • Cloud Native PatternsCloud Native Patterns
    • Building MicroservicesBuilding Microservices
    • Domain-Driven DesignDomain-Driven Design

    Online Resources:Online Resources:

    • Official architecture documentation from AWS/Azure/Alibaba CloudOfficial architecture documentation from AWS/Azure/Alibaba Cloud
    • CNCF (Cloud Native Computing Foundation) project documentationCNCF (Cloud Native Computing Foundation) project documentation
    • Tech blogs from major companies (Netflix Tech Blog, Alibaba Tech, etc.)Tech blogs from major companies (Netflix Tech Blog, Alibaba Tech, etc.)

    ------

    8. Glossary8. Glossary

    TermFull NameExplanation
    Backendโ€”Server-side system responsible for business logic, data storage, and external APIs
    CGICommon Gateway InterfaceEarly dynamic web technology; processes requests via scripts and returns results
    Monolithโ€”Monolithic architecture; packages all business logic in a single application
    Microservicesโ€”Microservices architecture; splits business logic into multiple independent services
    Containerโ€”Containerization technology; packages applications and dependencies into portable units
    K8sKubernetesContainer orchestration platform for scheduling, scaling, and governing containers
    Service Meshโ€”Service mesh; responsible for inter-service communication governance, observability, and security in microservices
    Serverlessโ€”Serverless computing; developers write only functions, the platform automatically runs and scales them
    BaaSBackend as a ServicePlug-and-play backend cloud services (authentication, database, payments, etc.)
    CI/CDContinuous Integration / DeliveryAutomated testing and deployment pipelines
    Observabilityโ€”Using logs, metrics, and traces to understand system runtime state