0
0
LLDsystem_design~12 mins

Split strategies (equal, exact, percentage) in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Split strategies (equal, exact, percentage)

This system manages how a total amount is divided among multiple recipients using different split strategies: equal, exact, and percentage. It ensures accurate distribution based on user input and handles validations to prevent errors.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Split Service
  |       |        |
  v       v        v
Equal   Exact   Percentage
Handler Handler Handler
  |       |        |
  v       v        v
Database (Split Records)
  |
  v
Cache (Recent Splits)
Components
User
client
Initiates split requests with chosen strategy and amounts
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to the Split Service and handles authentication
Split Service
service
Processes split requests and delegates to specific strategy handlers
Equal Handler
service_component
Calculates equal splits among recipients
Exact Handler
service_component
Processes splits with exact amounts per recipient
Percentage Handler
service_component
Calculates splits based on percentage values per recipient
Database (Split Records)
database
Stores split transaction records and user data
Cache (Recent Splits)
cache
Caches recent split results for faster retrieval
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewaySplit Service
Split ServiceCache (Recent Splits)
Cache (Recent Splits)Split Service
Split ServiceEqual Handler / Exact Handler / Percentage Handler
Equal Handler / Exact Handler / Percentage HandlerSplit Service
Split ServiceDatabase (Split Records)
Split ServiceCache (Recent Splits)
Split ServiceAPI Gateway
API GatewayUser
Failure Scenario
Component Fails:Database (Split Records)
Impact:New split transactions cannot be saved, risking data loss; reads may fallback to cache but may be stale
Mitigation:Use database replication and failover; cache serves recent splits temporarily; alert system triggers for manual intervention
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for deciding how to split the amount based on the strategy?
AAPI Gateway
BSplit Service
CLoad Balancer
DCache
Design Principle
This architecture cleanly separates concerns by using dedicated handlers for each split strategy, enabling easy extension and maintenance. Caching improves performance by avoiding repeated calculations, and the use of load balancer and API gateway ensures scalability and security.