Bird
Raised Fist0
Microservicessystem_design~20 mins

Services and networking 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
🎖️
Services and Networking Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing Service Communication in Microservices

You have three microservices: User, Order, and Inventory. Which communication pattern best reduces tight coupling and improves scalability?

AUsing an asynchronous message broker for event-driven communication
BSynchronous HTTP calls directly between services for every request
CEmbedding all logic into a single monolithic service
DUsing shared database tables for communication between services
Attempts:
2 left
💡 Hint

Think about how services can work independently without waiting on each other.

scaling
intermediate
2:00remaining
Scaling Service Discovery in a Microservices Environment

You have 100 microservices instances running across multiple servers. Which approach best supports automatic service discovery and load balancing?

AManually configure IP addresses of all instances in each service
BUse a centralized service registry with health checks and client-side load balancing
CUse DNS with static entries for each service instance
DHardcode service endpoints in configuration files
Attempts:
2 left
💡 Hint

Consider how services can find healthy instances dynamically without manual updates.

tradeoff
advanced
2:00remaining
Choosing Between API Gateway and Service Mesh

Which statement best describes a key tradeoff when choosing between an API Gateway and a Service Mesh for microservices networking?

AAPI Gateway centralizes external client requests, while Service Mesh manages internal service-to-service communication with fine-grained control
BAPI Gateway handles internal service-to-service communication, while Service Mesh manages external client requests
CAPI Gateway and Service Mesh are identical and interchangeable in all scenarios
DService Mesh replaces the need for load balancers, while API Gateway replaces the need for service discovery
Attempts:
2 left
💡 Hint

Think about the roles of API Gateway and Service Mesh in handling traffic.

🧠 Conceptual
advanced
2:00remaining
Understanding Circuit Breaker Pattern in Microservices

What is the primary purpose of the circuit breaker pattern in microservices networking?

ATo encrypt all network traffic between services
BTo route requests to the nearest service instance geographically
CTo automatically scale services based on load
DTo prevent a service from repeatedly calling a failing service and causing cascading failures
Attempts:
2 left
💡 Hint

Consider how to protect the system when one service is down or slow.

estimation
expert
3:00remaining
Estimating Network Bandwidth for Microservices Communication

You have 50 microservices instances communicating via REST APIs. Each instance sends 100 requests per second, each request is 2KB, and the response is 3KB. Estimate the total network bandwidth required in Mbps.

A80 Mbps
B100 Mbps
C160 Mbps
D120 Mbps
Attempts:
2 left
💡 Hint

Calculate total data per second and convert bytes to bits, then to Mbps.

Practice

(1/5)
1. What is the main purpose of service discovery in a microservices architecture?
easy
A. To manage database transactions
B. To store user data securely
C. To help services find and communicate with each other dynamically
D. To handle user authentication

Solution

  1. Step 1: Understand service discovery role

    Service discovery allows services to locate each other without hardcoding addresses.
  2. Step 2: Match purpose with options

    Only To help services find and communicate with each other dynamically describes dynamic service location, others relate to different concerns.
  3. Final Answer:

    To help services find and communicate with each other dynamically -> Option C
  4. Quick Check:

    Service discovery = dynamic service location [OK]
Hint: Service discovery = finding services automatically [OK]
Common Mistakes:
  • Confusing service discovery with authentication
  • Thinking it manages databases
  • Assuming it stores user data
2. Which of the following is the correct way to specify a REST API call in microservices networking?
easy
A. FETCH /users/api HTTP/1.0
B. POST /api/v1/users HTTP/1.1
C. CONNECT users /api/v1 HTTP/2
D. SEND /api/users HTTP/1.1

Solution

  1. Step 1: Identify standard HTTP methods and syntax

    REST APIs use standard HTTP methods like GET, POST, PUT, DELETE with URI paths and HTTP version.
  2. Step 2: Match correct syntax

    POST /api/v1/users HTTP/1.1 uses POST method, valid URI, and HTTP/1.1 version correctly; others use invalid methods or syntax.
  3. Final Answer:

    POST /api/v1/users HTTP/1.1 -> Option B
  4. Quick Check:

    REST API call = HTTP method + URI + version [OK]
Hint: REST calls use standard HTTP verbs and URIs [OK]
Common Mistakes:
  • Using non-standard HTTP methods
  • Incorrect URI format
  • Wrong HTTP version syntax
3. Given the following microservice call sequence:
Service A calls Service B via HTTP.
Service B calls Service C via gRPC.
Service C responds with data.

What is the correct order of communication protocols used in this flow?
medium
A. Only gRPC
B. gRPC then HTTP
C. Only HTTP
D. HTTP then gRPC

Solution

  1. Step 1: Trace the call sequence

    Service A calls B using HTTP first, then B calls C using gRPC.
  2. Step 2: Identify protocol order

    The communication starts with HTTP and then switches to gRPC.
  3. Final Answer:

    HTTP then gRPC -> Option D
  4. Quick Check:

    Call sequence protocols = HTTP then gRPC [OK]
Hint: Follow call chain to list protocols in order [OK]
Common Mistakes:
  • Mixing protocol order
  • Assuming only one protocol is used
  • Ignoring protocol differences
4. A microservice is failing to connect to another service using its hardcoded IP address. What is the most likely cause and fix?
medium
A. IP address changed; use service discovery instead of hardcoding
B. Service is down; restart the service
C. Network cable unplugged; check physical connections
D. Firewall blocking traffic; disable firewall

Solution

  1. Step 1: Identify problem with hardcoded IP

    Hardcoded IPs break when services move or scale, causing connection failures.
  2. Step 2: Recommend dynamic service discovery

    Using service discovery allows services to find current addresses dynamically, fixing the issue.
  3. Final Answer:

    IP address changed; use service discovery instead of hardcoding -> Option A
  4. Quick Check:

    Hardcoded IP failure = use service discovery [OK]
Hint: Avoid hardcoded IPs; use service discovery [OK]
Common Mistakes:
  • Restarting services without checking addresses
  • Ignoring dynamic environment changes
  • Disabling firewall without cause
5. You are designing a microservices system where services must communicate securely and efficiently. Which combination of networking components is best to ensure service discovery, secure communication, and load balancing?
hard
A. Service registry for discovery, TLS for security, and API gateway for load balancing
B. Static IPs for discovery, HTTP for communication, and DNS for load balancing
C. Manual config files for discovery, plain TCP sockets, and round-robin DNS
D. No discovery needed, use UDP for speed, and client-side load balancing

Solution

  1. Step 1: Identify components for service discovery

    A service registry dynamically tracks services, enabling discovery.
  2. Step 2: Choose secure communication and load balancing

    TLS encrypts data for security; API gateway can handle load balancing efficiently.
  3. Step 3: Evaluate other options

    Static IPs and manual configs lack flexibility; plain TCP and UDP lack security; DNS load balancing is limited.
  4. Final Answer:

    Service registry for discovery, TLS for security, and API gateway for load balancing -> Option A
  5. Quick Check:

    Discovery + TLS + API gateway = secure scalable system [OK]
Hint: Combine registry, TLS, and gateway for best networking [OK]
Common Mistakes:
  • Using static IPs instead of dynamic discovery
  • Ignoring encryption needs
  • Relying solely on DNS for load balancing