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
Recall & Review
beginner
What does high cohesion mean in microservices?
High cohesion means that a microservice focuses on a single, well-defined task or responsibility, making it easier to understand, maintain, and scale.
Click to reveal answer
beginner
Why is high cohesion important in microservices?
High cohesion helps reduce complexity, improves code quality, and allows teams to work independently on different services without causing conflicts.
Click to reveal answer
intermediate
How does high cohesion relate to service boundaries in microservices?
High cohesion guides defining clear service boundaries so each microservice handles related functions, avoiding mixing unrelated features in one service.
Click to reveal answer
intermediate
Give an example of low cohesion in a microservice.
A microservice that handles user authentication, order processing, and payment all together has low cohesion because it mixes unrelated responsibilities.
Click to reveal answer
intermediate
How does high cohesion improve scalability in microservices?
Because each microservice handles a focused task, it can be scaled independently based on its specific load, making the system more efficient.
Click to reveal answer
What is a key characteristic of a highly cohesive microservice?
AIt handles many unrelated tasks.
BIt focuses on a single responsibility.
CIt depends on many other services.
DIt has a large codebase.
✗ Incorrect
High cohesion means focusing on a single responsibility to keep the service clear and manageable.
Which of the following is a benefit of high cohesion in microservices?
AEasier to scale independently.
BHarder to maintain.
CMore dependencies.
DIncreased complexity.
✗ Incorrect
High cohesion allows each service to be scaled independently based on its workload.
What problem can low cohesion cause in microservices?
ABetter team autonomy.
BSimplified deployment.
CClear service boundaries.
DMixing unrelated features in one service.
✗ Incorrect
Low cohesion mixes unrelated features, making services complex and harder to maintain.
How does high cohesion affect team collaboration?
ATeams can work independently on different services.
BTeams must coordinate on every change.
CTeams share the same codebase for all features.
DTeams cannot own services.
✗ Incorrect
High cohesion allows teams to own focused services and work independently.
Which practice supports achieving high cohesion in microservices?
ACombining multiple unrelated features in one service.
BSharing databases between services.
CDefining clear service boundaries based on business capabilities.
DAvoiding service decomposition.
✗ Incorrect
Clear service boundaries based on business capabilities help maintain high cohesion.
Explain what high cohesion means in microservices and why it matters.
Think about how a focused service is easier to manage.
You got /3 concepts.
Describe how high cohesion influences the design of service boundaries in a microservices architecture.
Consider how to split a system into smaller parts.
You got /3 concepts.
Practice
(1/5)
1. What does high cohesion mean in microservices architecture?
easy
A. Using a single database for all microservices
B. Splitting every function into separate services regardless of relation
C. Combining unrelated tasks to reduce the number of services
D. Grouping related tasks and responsibilities within a single service
Solution
Step 1: Understand the meaning of cohesion
Cohesion means how closely related the tasks inside a module or service are.
Step 2: Apply cohesion to microservices
High cohesion means grouping related tasks in one service to keep it focused and manageable.
Final Answer:
Grouping related tasks and responsibilities within a single service -> Option D
Quick Check:
High cohesion = grouping related tasks [OK]
Hint: High cohesion means related tasks stay together [OK]
Common Mistakes:
Thinking high cohesion means splitting every function separately
Confusing cohesion with coupling
Believing unrelated tasks should be combined
Assuming database design defines cohesion
2. Which of the following is the correct way to describe a microservice with high cohesion?
easy
A. A service that manages all user-related operations like profile, login, and preferences
B. A service that mixes order processing and inventory updates randomly
C. A service that handles user authentication and payment processing
D. A service that only stores data without any business logic
Solution
Step 1: Identify related tasks in options
A service that manages all user-related operations like profile, login, and preferences groups user-related operations which are closely related.
Step 2: Check other options for unrelated tasks
Options A and B mix unrelated tasks; D lacks business logic, so not cohesive.
Final Answer:
A service that manages all user-related operations like profile, login, and preferences -> Option A
Quick Check:
High cohesion = related user tasks together [OK]
Hint: Look for grouping of related tasks in one service [OK]
Common Mistakes:
Choosing options that mix unrelated responsibilities
Ignoring business logic in cohesion
Confusing data storage with service responsibility
Assuming more tasks always mean better cohesion
3. Consider a microservice design where the OrderService handles order creation, payment processing, and shipping updates. What is the likely issue with this design regarding high cohesion?
medium
A. The service has low cohesion because it mixes unrelated responsibilities
B. The service has high cohesion because all tasks relate to orders
C. The service is scalable because it handles multiple tasks
D. The service is loosely coupled with other services
Solution
Step 1: Analyze the tasks in OrderService
Order creation, payment, and shipping are different domains with distinct logic.
Step 2: Evaluate cohesion
Mixing payment and shipping with order creation lowers cohesion because responsibilities differ.
Final Answer:
The service has low cohesion because it mixes unrelated responsibilities -> Option A
Quick Check:
Mixed tasks = low cohesion [OK]
Hint: Different domains in one service reduce cohesion [OK]
Common Mistakes:
Assuming all order-related tasks are always cohesive
Confusing scalability with cohesion
Ignoring domain boundaries
Believing loosely coupled means high cohesion
4. A microservice named InventoryService currently manages stock levels and supplier payments. What is the best fix to improve high cohesion?
medium
A. Combine InventoryService with OrderService
B. Add customer order tracking to InventoryService
C. Split supplier payments into a separate PaymentService
D. Keep all tasks in InventoryService for simplicity
Solution
Step 1: Identify unrelated responsibilities
Supplier payments are unrelated to stock level management.
Step 2: Suggest separation for high cohesion
Moving payments to a dedicated PaymentService improves cohesion by grouping related tasks.
Final Answer:
Split supplier payments into a separate PaymentService -> Option C
Quick Check:
Separate unrelated tasks to improve cohesion [OK]
Hint: Separate unrelated tasks into different services [OK]
Common Mistakes:
Adding unrelated tasks to the same service
Combining unrelated services
Ignoring cohesion for simplicity
Confusing cohesion with coupling
5. You are designing a microservices system for an e-commerce platform. To ensure high cohesion, which of the following service groupings is best?
C. One big service handling users, orders, payments, shipping, and inventory
D. Split every function into its own microservice regardless of relation
Solution
Step 1: Evaluate grouping of related tasks
UserService (user profiles, authentication), OrderService (orders, payments), ShippingService (shipping updates, tracking) groups related tasks logically by domain, supporting high cohesion.
Step 2: Compare with other options
UserService (user profiles, payments), OrderService (orders, shipping), InventoryService (stock levels, payments) mixes payments in unrelated services; C is a monolith; D over-splits causing low cohesion.