Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 106

    Architecture Challenges

    Whiteboard architecture problems train the same muscles as Orders RFCs: requirements, estimates, components, and trade-offs.

    Course progress0%
    Focus
    12 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Whiteboard architecture problems train the same muscles as Orders RFCs: requirements, estimates, components, and trade-offs. These challenges stretch messaging, geo, feeds, ledgers, and multi-region active-active — then ask you to map lessons back to a Spring Boot 3 / Java 21 service mesh.

    There is no single correct diagram. There is a well-justified one with failure modes.

    Practise out loud; timebox; write decisions down.

    Purpose of this lesson

    Complete five architecture whiteboard challenges with estimates, diagrams, and explicit trade-offs tied to Boot 3 realities.

    Understanding the topic

    Five classic prompts — deliver artifacts, not vibes.

    • WhatsApp @ 1B users — messaging, presence, delivery receipts.
    • Uber matching — riders, drivers, geo-indexing.
    • Instagram feed — fan-out vs fan-in trade-offs.
    • Bank ledger — strong consistency, audit, idempotent transfers.
    • Multi-region active-active — Spring Boot Orders across regions.

    Step-by-step explanation

    1. Clarify FR/NFR and write three scale assumptions.
    2. Draw high-level boxes; mark sync vs async edges.
    3. Deep-dive the hardest component (storage or consistency).
    4. List three failures and mitigations; map what would be Boot 3 services vs managed cloud.

    Informative example

    Ledger challenge — decision card.

    bash
    Prompt: Design a bank ledger for TechLearningPRO wallet transfers
    Constraints: exactly-once money movement under client retries; audit forever
    Decisions:
    - Postgres as source of truth; UNIQUE(transfer_id)
    - Double-entry rows in ledger_lines inside one @Transactional boundary
    - Outbox → Kafka for notifications (not for money truth)
    - Idempotent API: POST /transfers with Idempotency-Key
    - No multi-region active-active for balances (choose primary region + async read replicas)
    Trade-off: simpler consistency vs higher cross-region write latency
    Boot 3 note: keep money in domain service; no javax.*; Java 21 virtual threads for notification fan-out only

    Real-world use

    TechLearningPRO evaluated active-active Orders across two regions and rejected it for checkout writes after estimating conflict rates on inventory reservations. They chose primary-region writes + read replicas — the same trade-off a strong ledger whiteboard answer surfaces.

    Security implications

    Architecture choices change blast radius.

    • Cross-region replication of PII needs encryption and residency review.
    • Admin planes stay in one tightly controlled network.
    • Secrets per region — never a single shared long-lived credential in diagrams.

    Best practices

    • Narrate alternatives you rejected.
    • Separate control plane from data plane.
    • Always end with observability and rollback.

    Common mistakes

    • Drawing twenty boxes before stating RPS assumptions.
    • Choosing multi-region active-active without conflict resolution.
    • Putting money truth in Kafka instead of the database transaction.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    3 questions
    1AdvancedQuestionFan-out on write vs fan-in on read for feeds?+

    Answer

    Fan-out precomputes timelines (fast read, heavy write); fan-in aggregates at read time (cheap write, heavier read) — celebrities often need hybrids.
    2IntermediateQuestionWhy keep money truth in the DB transaction?+

    Answer

    Exactly-once business effects need a transactional boundary; queues are for propagation, not balances.
    3IntermediateQuestionWhat breaks in naive active-active inventory?+

    Answer

    Two regions can accept the last unit without a conflict protocol — oversell.

    Hands-on exercise

    Whiteboard pack (45 min each). 1) WhatsApp-scale messaging — include ack/receipt flow. 2) Uber matching — geo index choice + hotspot handling. 3) Instagram feed — fan-out on write vs read; when to hybrid. 4) Bank ledger — idempotent transfer sequence diagram. 5) Active-active Orders — pick a conflict strategy or justify single-primary writes. Deliverable per prompt: 1 page assumptions, 1 diagram, 5 trade-off bullets, 3 failure modes.

    Summary

    Architecture challenges build senior judgment. Next: quiz yourself across the whole Boot course.

    Ready to mark this lesson complete?Track your journey across the entire course.