Bird
Raised Fist0
Microservicessystem_design~20 mins

Identifying service boundaries in Microservices - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Service Boundary Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identifying service boundaries based on business capabilities

Which of the following best describes how to identify service boundaries in a microservices architecture?

AGroup services by technical layers such as database, API, and UI to separate concerns.
BSplit services based on the size of the development team to balance workload.
CCreate one large service that handles all business logic to reduce network calls.
DDefine services around distinct business capabilities or domains to ensure loose coupling.
Attempts:
2 left
💡 Hint

Think about how to keep services independent and aligned with business goals.

Architecture
intermediate
2:00remaining
Choosing service boundaries for an e-commerce platform

You are designing microservices for an e-commerce platform. Which service boundary division is most appropriate?

ASeparate services for user authentication, product catalog, order processing, and payment handling.
BSeparate services for frontend UI, backend API, and database access.
CSeparate services by geographic region to optimize latency.
DSeparate services by programming language used for development.
Attempts:
2 left
💡 Hint

Consider how to align services with distinct business functions.

scaling
advanced
2:00remaining
Scaling microservices by service boundaries

Which approach best supports scaling microservices independently based on service boundaries?

ADesign services so that each handles multiple unrelated business functions to maximize resource use.
BDesign services around single business capabilities so they can be scaled independently as demand varies.
CCombine all services into one monolith to simplify scaling decisions.
DScale services only by increasing database capacity regardless of service boundaries.
Attempts:
2 left
💡 Hint

Think about how service boundaries affect independent scaling.

tradeoff
advanced
2:00remaining
Tradeoffs in defining service boundaries

What is a common tradeoff when defining very fine-grained service boundaries in microservices?

AImproved performance due to fewer network calls between services.
BSimpler deployment because fewer services exist to manage.
CIncreased complexity in communication and data consistency across many small services.
DReduced fault tolerance because all logic is in one service.
Attempts:
2 left
💡 Hint

Consider what happens when services are too small and numerous.

estimation
expert
3:00remaining
Estimating number of microservices for a ride-sharing app

You are tasked with estimating the number of microservices needed for a ride-sharing app. The app includes user management, ride matching, payment processing, driver tracking, and notifications. Which is the most reasonable estimate?

A5 or more services, each focused on a distinct business capability like user management, ride matching, payment, driver tracking, and notifications.
B2 services: one for users and rides, one for payments and notifications.
C10 services, splitting each feature into multiple smaller services regardless of business boundaries.
D1 service handling all features to reduce complexity.
Attempts:
2 left
💡 Hint

Think about aligning services with clear business capabilities without over-fragmenting.

Practice

(1/5)
1. Which of the following best describes the primary goal when identifying service boundaries in microservices?
easy
A. Create services based on the number of developers available
B. Split services evenly by code size
C. Group all database operations into one service
D. Divide the system based on business capabilities and data ownership

Solution

  1. Step 1: Understand the purpose of service boundaries

    Service boundaries should reflect business capabilities to ensure clear ownership and independent deployment.
  2. Step 2: Evaluate the options

    Options B, C, and D focus on technical or team size factors, which are less effective than business-driven boundaries.
  3. Final Answer:

    Divide the system based on business capabilities and data ownership -> Option D
  4. Quick Check:

    Business capabilities = A [OK]
Hint: Match services to business functions, not code size or teams [OK]
Common Mistakes:
  • Splitting services by code size only
  • Grouping all database logic in one service
  • Ignoring business domain boundaries
2. Which of the following is the correct way to define a microservice boundary?
easy
A. A service that handles user authentication and profile management
B. A service that mixes payment processing and product catalog updates
C. A service that only manages database connections
D. A service that handles logging for all other services

Solution

  1. Step 1: Identify cohesive responsibilities

    A good service boundary groups related business functions, like authentication and profile management.
  2. Step 2: Check for unrelated responsibilities

    Options A, B, and C mix unrelated concerns or are cross-cutting, which should be separate services or infrastructure.
  3. Final Answer:

    A service that handles user authentication and profile management -> Option A
  4. Quick Check:

    Cohesive business functions = D [OK]
Hint: Group related business tasks in one service [OK]
Common Mistakes:
  • Combining unrelated business functions
  • Creating services for technical concerns only
  • Mixing cross-cutting concerns inside business services
3. Given a system with services: OrderService managing orders, InventoryService managing stock, and PaymentService handling payments, which service boundary violation is shown if OrderService directly updates stock quantities?
medium
A. OrderService is violating the single responsibility principle by managing inventory data
B. OrderService is correctly handling all order-related data including stock
C. PaymentService should update stock quantities instead
D. InventoryService should not exist separately from OrderService

Solution

  1. Step 1: Analyze service responsibilities

    OrderService should focus on orders; InventoryService owns stock data and updates.
  2. Step 2: Identify boundary violation

    OrderService updating stock breaks clear ownership and single responsibility principles.
  3. Final Answer:

    OrderService is violating the single responsibility principle by managing inventory data -> Option A
  4. Quick Check:

    Single responsibility violation = B [OK]
Hint: Each service owns its data; no direct updates outside boundaries [OK]
Common Mistakes:
  • Allowing services to update data owned by others
  • Confusing payment service role
  • Merging unrelated services unnecessarily
4. A team notices that their UserService and NotificationService are tightly coupled because UserService calls NotificationService directly for every user update. What is the best way to fix this boundary issue?
medium
A. Make NotificationService call UserService instead
B. Merge both services into one to avoid communication
C. Use an event-driven approach where UserService emits events and NotificationService listens
D. Remove NotificationService and handle notifications inside UserService

Solution

  1. Step 1: Understand tight coupling problem

    Direct calls create dependencies that reduce service independence.
  2. Step 2: Apply event-driven design

    Emitting events decouples services, allowing independent scaling and deployment.
  3. Final Answer:

    Use an event-driven approach where UserService emits events and NotificationService listens -> Option C
  4. Quick Check:

    Event-driven decoupling = C [OK]
Hint: Use events to decouple services, not direct calls [OK]
Common Mistakes:
  • Merging services unnecessarily
  • Reversing call direction without decoupling
  • Ignoring decoupling benefits
5. You are designing a microservices system for an e-commerce platform. Which approach best defines service boundaries to maximize team autonomy and scalability?
hard
A. Create services based on technical layers like UI, Business Logic, and Database Access
B. Define services around distinct business domains like Catalog, Orders, Payments, and Shipping, each owning its data and APIs
C. Split services by database tables regardless of business function
D. Group all user-related features into one large service to reduce communication

Solution

  1. Step 1: Identify business domain boundaries

    Services aligned with business domains allow clear ownership and independent scaling.
  2. Step 2: Avoid technical or data-layer splits

    Splitting by technical layers or tables causes tight coupling and reduces autonomy.
  3. Step 3: Consider team autonomy and scalability

    Domain-based services enable teams to work independently and scale services as needed.
  4. Final Answer:

    Define services around distinct business domains like Catalog, Orders, Payments, and Shipping, each owning its data and APIs -> Option B
  5. Quick Check:

    Domain-driven design = A [OK]
Hint: Align services with business domains for autonomy and scale [OK]
Common Mistakes:
  • Splitting by technical layers instead of business domains
  • Grouping unrelated features together
  • Ignoring data ownership in service design