0
0
Microservicessystem_design~10 mins

Ambassador pattern in Microservices - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Ambassador pattern
Growth Table: Ambassador Pattern Scaling
Users/TrafficWhat Changes
100 usersSingle ambassador instance per service; low network overhead; simple routing and monitoring.
10,000 usersMultiple ambassador instances per service; increased network traffic; ambassador handles retries, circuit breaking; load balancing needed.
1,000,000 usersAmbassador instances scale horizontally; network bandwidth grows; ambassador becomes critical for service discovery and security; monitoring and logging volume increases.
100,000,000 usersMassive horizontal scaling of ambassadors; potential network bottlenecks; need for ambassador clustering or federation; advanced caching and rate limiting; observability systems must scale.
First Bottleneck

The first bottleneck is the ambassador proxy instances themselves. As traffic grows, each ambassador handles more connections and network processing. CPU and memory limits on ambassador containers or VMs cause latency and throughput issues before backend services do.

Scaling Solutions
  • Horizontal scaling: Add more ambassador instances per service to distribute load.
  • Load balancing: Use external load balancers or service mesh features to balance traffic among ambassadors.
  • Caching: Implement response caching in ambassadors to reduce backend calls.
  • Connection pooling: Reuse connections to backend services to reduce overhead.
  • Rate limiting and circuit breaking: Prevent overload and isolate failures at ambassador level.
  • Monitoring and autoscaling: Use metrics to trigger scaling of ambassador pods or instances.
  • Network optimization: Use efficient protocols and compression to reduce bandwidth.
Back-of-Envelope Cost Analysis
  • Each ambassador handles ~1000-5000 concurrent connections.
  • At 1 million users, assuming 10 requests per second per user, total requests = 10 million QPS.
  • To handle 10 million QPS, need ~2000 ambassador instances (assuming 5000 QPS per instance).
  • Network bandwidth: 1 Gbps = 125 MB/s; high traffic requires multiple 10 Gbps links or cloud bandwidth scaling.
  • Storage for logs and metrics grows with traffic; plan for scalable observability backend.
Interview Tip

Start by explaining the ambassador pattern role as a proxy for microservices. Discuss how it helps with cross-cutting concerns like retries and monitoring. Then analyze scaling by identifying the ambassador as the first bottleneck. Propose horizontal scaling and caching as solutions. Finally, mention observability and network considerations to show a full picture.

Self Check

Your ambassador proxy handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?

Answer: Add more ambassador instances to horizontally scale and distribute the increased load, ensuring each instance stays within its capacity.

Key Result
The ambassador proxy is the first bottleneck as traffic grows; horizontal scaling and caching at the ambassador layer are key to maintaining performance.