Transitioning to Microservices: Key Insights

Aug 5, 2024

Transitioning from Monolith to Microservices

Overview

  • Moving from a monolithic application to a cloud-based microservices architecture involves several challenges.
  • In a monolith, all functionalities are on the same server.
  • Example: Updating inventory after an order is a local call in a monolith.
  • In microservices, services can be dynamic, requiring routing and registration methods.

Service Discovery

  • Definition: Process of locating resources (applications/services) on a network.
  • Requires a Service Registry: a database storing services and their locations.
  • Example of Service Registry: DNS (Domain Name Service) which maps IP addresses to domain names.
  • Importance of keeping the Service Registry up to date:
    • Remove services that shut down.
    • Add new services as they start.
    • Remove unhealthy services from the registry.

Types of Service Discovery

1. Where is Service Discovery Happening?

  • Client-Side Service Discovery:
    • Service A queries the Service Registry for the location of Service B and communicates directly.
    • Example: Similar to how a browser uses DNS to find a website.
  • Server-Side Service Discovery:
    • Service A communicates through a Proxy that queries the Service Registry and redirects the request to Service B.

2. How is the Service Registry Maintained?

  • Self Registration:
    • Each service updates the Service Registry with its status.
    • Pros: Fine-grained status updates.
    • Cons: Services hanging or not responding can't update the registry; requires specific implementations for each language.
  • Third-party Registration:
    • An external application (Registrar) observes and updates the Service Registry.
    • Types: Sidecar or Service Orchestration Engine (e.g., Kubernetes).
    • Pros: Language agnostic, can check unresponsive services.
    • Cons: Requires additional infrastructure or limited to services deployed within the orchestration engine.

Pros and Cons Summary

Client-Side Service Discovery

  • Pros:
    • Simple implementation.
  • Cons:
    • Requires specific implementations for each programming language.
    • More coupling with Service Registry.

Server-Side Service Discovery

  • Pros:
    • Language agnostic; no direct coupling with Service Registry.
  • Cons:
    • Requires infrastructure setup.

Self Registration

  • Pros:
    • Detailed status awareness.
  • Cons:
    • Potential outdated registry for unresponsive services.
    • Language-specific implementations required.

Third-party Registration

  • Pros:
    • Language agnostic, external checks for service status.
  • Cons:
    • Dependency on a specific registration system.
    • Limited to services within the orchestration engine.

Open Questions & Future Topics

  • Challenges of deploying services outside of the main infrastructure.
  • Handling performance issues and traffic routing intelligently.
  • Introduction of Service Mesh as a solution for more complex routing and performance management.

Conclusion

  • Various Service Discovery approaches exist, each with benefits and drawbacks.
  • Performance and smart traffic routing are advanced topics to explore further.