Bird
Raised Fist0
Microservicessystem_design~7 mins

Parallel running in Microservices - System Design Guide

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
Problem Statement
When deploying a new version of a microservice, switching directly can cause system downtime or unexpected failures that impact users. Without a safe way to compare old and new versions, bugs or performance issues may go unnoticed until after full rollout.
Solution
Parallel running deploys the new microservice version alongside the old one, routing a portion of live traffic to both simultaneously. This allows real-time comparison of outputs and performance under production load, enabling safe validation before full cutover.
Architecture
Client/API
Load Balancer
Old Version
Microservice

This diagram shows a load balancer routing client requests to both old and new microservice versions in parallel for comparison.

Trade-offs
✓ Pros
Enables safe validation of new microservice versions under real production load.
Reduces risk of downtime by allowing rollback to old version instantly.
Helps detect subtle bugs or performance regressions before full deployment.
✗ Cons
Requires double infrastructure resources during parallel run period.
Increases complexity of traffic routing and result comparison.
May introduce data consistency challenges if both versions write to shared storage.
Use when deploying critical microservices where downtime or bugs have high impact, especially at scale above thousands of requests per second.
Avoid when system load is low (under 1000 req/sec) or infrastructure cost constraints prevent running duplicate services.
Real World Examples
Netflix
Netflix uses parallel running to deploy new streaming service versions alongside old ones, ensuring smooth user experience without interruptions.
Uber
Uber runs new dispatch microservices in parallel with existing ones to validate routing logic under live traffic before full rollout.
Amazon
Amazon deploys new versions of order processing microservices in parallel to detect errors early and avoid order failures.
Code Example
The before code uses only the old microservice version, risking downtime on switch. The after code runs both old and new versions in parallel, compares their outputs, and returns the old version's response until the new one is validated.
Microservices
### Before: Direct switch without parallel running
class Microservice:
    def process(self, request):
        # Old version logic
        return "old response"

service = Microservice()
request = {}  # Added to define 'request'
response = service.process(request)


### After: Parallel running with traffic split and comparison
class OldMicroservice:
    def process(self, request):
        return "old response"

class NewMicroservice:
    def process(self, request):
        return "new response"

class ParallelRunner:
    def __init__(self):
        self.old_service = OldMicroservice()
        self.new_service = NewMicroservice()

    def process(self, request):
        old_resp = self.old_service.process(request)
        new_resp = self.new_service.process(request)
        # Compare responses for validation
        if old_resp != new_resp:
            print("Warning: Responses differ")
        # Return old response to client until new version is fully validated
        return old_resp

runner = ParallelRunner()
request = {}  # Added to define 'request'
response = runner.process(request)
OutputSuccess
Alternatives
Blue-Green Deployment
Blue-green switches all traffic instantly between two environments rather than splitting traffic simultaneously.
Use when: Choose blue-green when instant cutover with minimal parallel resource usage is preferred and rollback speed is critical.
Canary Deployment
Canary gradually shifts a small percentage of traffic to new version instead of running both fully in parallel.
Use when: Choose canary when incremental exposure to new version is needed to limit blast radius of failures.
Summary
Parallel running deploys new and old microservice versions simultaneously to compare outputs under real traffic.
It reduces downtime risk by validating new versions before full cutover and enables quick rollback.
This pattern is best for critical services at scale but requires extra resources and complexity temporarily.

Practice

(1/5)
1. What is the main purpose of parallel running in microservices?
easy
A. To run old and new systems together to ensure smooth transition
B. To replace the old system immediately without testing
C. To run only the new system and discard the old one
D. To run multiple unrelated services in parallel

Solution

  1. Step 1: Understand the concept of parallel running

    Parallel running means running old and new systems side by side to compare their outputs and ensure the new system works correctly.
  2. Step 2: Identify the purpose in microservices

    This approach helps catch errors and ensures a smooth transition before fully switching to the new system.
  3. Final Answer:

    To run old and new systems together to ensure smooth transition -> Option A
  4. Quick Check:

    Parallel running = run old and new systems together [OK]
Hint: Parallel running means running old and new systems side by side [OK]
Common Mistakes:
  • Thinking parallel running means immediate replacement
  • Confusing parallel running with running unrelated services
  • Assuming old system is discarded immediately
2. Which of the following is the correct way to implement parallel running in a microservices upgrade?
easy
A. Deploy new microservice version alongside old one and route a copy of requests to both
B. Stop old microservice and deploy new one immediately
C. Deploy new microservice and ignore old service logs
D. Run new microservice only during off-peak hours

Solution

  1. Step 1: Understand deployment in parallel running

    Parallel running requires both old and new versions to run simultaneously to compare results.
  2. Step 2: Identify correct routing method

    Routing a copy of requests to both versions allows output comparison without disrupting users.
  3. Final Answer:

    Deploy new microservice version alongside old one and route a copy of requests to both -> Option A
  4. Quick Check:

    Parallel running = deploy both and route requests to both [OK]
Hint: Route requests to both old and new services in parallel [OK]
Common Mistakes:
  • Stopping old service before testing new one
  • Ignoring logs from old service
  • Running new service only at specific times
3. Consider a microservice system where requests are sent to both old and new versions during parallel running. If the old service returns response A and the new service returns response B, what should the system do?
medium
A. Ignore the difference and continue using the new service
B. Switch back to the old service permanently
C. Stop the old service immediately
D. Log the difference and alert engineers for investigation

Solution

  1. Step 1: Understand output comparison in parallel running

    Parallel running compares outputs to detect discrepancies between old and new services.
  2. Step 2: Decide action on output mismatch

    If outputs differ, the system should log the difference and alert engineers to investigate before switching fully.
  3. Final Answer:

    Log the difference and alert engineers for investigation -> Option D
  4. Quick Check:

    Output mismatch = log and alert [OK]
Hint: Log and alert on output differences during parallel running [OK]
Common Mistakes:
  • Ignoring output differences
  • Stopping old service too early
  • Switching back permanently without investigation
4. A team implemented parallel running but noticed that the new service never receives any requests. What is the most likely cause?
medium
A. The new service crashed immediately after deployment
B. The routing logic is only sending requests to the old service
C. The old service is not logging requests
D. The new service is slower than the old one

Solution

  1. Step 1: Analyze routing in parallel running

    For parallel running, requests must be routed to both old and new services simultaneously.
  2. Step 2: Identify why new service gets no requests

    If new service never receives requests, routing likely sends all traffic only to old service.
  3. Final Answer:

    The routing logic is only sending requests to the old service -> Option B
  4. Quick Check:

    No requests to new service = routing issue [OK]
Hint: Check routing logic if new service gets no requests [OK]
Common Mistakes:
  • Assuming new service crashed without checking logs
  • Blaming old service logs
  • Thinking speed affects request routing
5. You are designing a parallel running strategy for a microservices system with high traffic. Which approach best balances safety and performance?
hard
A. Route 100% of traffic to new service and keep old service idle
B. Run new service only during low traffic hours without output comparison
C. Route 10% of traffic to new service and 90% to old service, compare outputs, then gradually increase new service traffic
D. Stop old service immediately and monitor new service logs

Solution

  1. Step 1: Understand gradual traffic shifting in parallel running

    Gradually increasing traffic to the new service while comparing outputs reduces risk and performance impact.
  2. Step 2: Evaluate options for safety and performance

    Routing a small portion initially and increasing after validation balances safety and system load.
  3. Final Answer:

    Route 10% of traffic to new service and 90% to old service, compare outputs, then gradually increase new service traffic -> Option C
  4. Quick Check:

    Gradual traffic shift with output comparison = safe and performant [OK]
Hint: Start small traffic to new service, compare, then increase [OK]
Common Mistakes:
  • Switching 100% traffic immediately
  • Skipping output comparison
  • Stopping old service too early