Skip to main content

Microservices

CategoryMonolithic architectureMicroservices architecture
DesignSingle code base with multiple interdependent functionsIndependent software components with autonomous functionality that communicate with each other using APIs
DevelopmentRequires less planning at the start, but gets increasingly complex to understand and maintainRequires more planning and infrastructure at the start, but gets easier to manage and maintain over time
DeploymentEntire application deployed as a single entityEvery microservice is an independent software entity that requires individual containerized deployment
DebuggingTrace the code path in the same environmentRequires advanced debugging tools to trace the data exchange between multiple microservices
ModificationSmall changes introduce greater risks as they impact the entire code baseYou can modify individual microservices without impacting the entire application
ScaleYou have to scale the entire application, even if only certain functional areas experience an increase in demandYou can scale individual microservices as required, which saves overall scaling costs
InvestmentLow upfront investment at the cost of increased ongoing and maintenance effortsAdditional time and cost investment to set up the required infrastructure and build team competency. However, long-term cost savings, maintenance, and adaptability
Use Cases
  • Small to medium-sized projects
  • Rapid prototyping and MVP development
  • Tightly coupled components
  • Resource constraints
  • Low-usage applications for improving cost efficiency
  • Large and complex systems
  • Scalability demands
  • Technology diversity
  • Independent deployment and continuous delivery
  • High fault tolerance and resilience
  • Large cross-functional development teams
  • Rapid evolving requirements

Architecture Overview​

VisualizationSpecs
  • Load Balancer: Distributes traffic to multiple backend services
  • CDN (Content Delivery Network): Speeds up content delivery by storing static content on distributed servers
  • API Gateway: Routes requests to relevant services, interacts with identity provider and service discovery
  • Identity Provider: Manages user authentication and authorization
  • Service Registry & Discovery: Registers and finds microservices, used by API gateway to locate services
  • Management: Monitors services
  • Microservices: Independently deployed and maintained in separate domains, each with its own database. Communicate via REST API or RPC

Project Structure​

AspectFile Type BasedModule/Feature BasedAtomic DesignClean Architecture
FocusFile types (JSX, CSS, tests)Functional modules, featuresUI component hierarchyBusiness logic separation (layers)
ScalabilitySmall to medium projectsMedium to large projectsScalable for complex UIsVery scalable, promotes separation of concerns
Use CasesSimple apps, prototypesComplex features, e-commerce applicationsComponent libraries, design systemsLarge-scale enterprise applications with strict separation

Migration​

  • Discovering system operations

    • Analyzing existing monolithic architecture
    • Identifying functionalities and dependencies
    • Documenting system components, interactions, and data flows
    • Conducting interviews with stakeholders to understand business requirements
    • Profiling system performance and resource utilization
    • Assessing scalability and maintainability issues in the current architecture
    • Generating system documentation and diagrams (e.g., entity-relationship diagrams, flowcharts)
  • Defining subdomains

    • Use domain-driven design approach
    • Identifying business capabilities and boundaries
    • Decomposing the monolithic system into cohesive subdomains
    • Prioritizing subdomains based on business impact and complexity
    • Defining bounded contexts for each subdomain
    • Documenting subdomain boundaries, responsibilities, and contexts
  • Designing services and their collaborations

    • Selecting appropriate communication protocols (e.g., REST, gRPC, GraphQL, Publish-Subscribe messaging)
    • Defining service interfaces and contracts
    • Choosing technology stacks for individual services
    • Designing fault-tolerant and resilient services
    • Implementing event-driven architectures or choreographed workflows
    • Establishing service discovery and registry mechanisms
    • Developing API gateways for routing and security
    • Implementing circuit breakers and retries for robustness
    • Designing data consistency strategies (e.g., eventual consistency, transactional boundaries)
    • Defining service versioning and backward compatibility policies
  • Evaluating a microservice architecture

    • Performing architectural reviews and inspections
    • Conducting proof-of-concept implementations
    • Analyzing trade-offs between microservices and monolithic architectures
    • Evaluating scalability, performance, and latency requirements
    • Assessing operational overhead and deployment complexities
    • Conducting cost-benefit analysis of microservices adoption
    • Benchmarking against key performance indicators (KPIs) and service level objectives (SLOs)
    • Considering organizational readiness and cultural implications
  • Refactoring a microservice architecture

    • Identifying code smells and anti-patterns in the existing architecture
    • Decomposing monolithic codebase into microservices
    • Applying domain-driven design principles for service boundaries
    • Implementing continuous integration and continuous deployment (CI/CD) pipelines
    • Automating testing, deployment, and monitoring processes
    • Establishing DevOps practices for collaboration and feedback loops
    • Implementing distributed tracing and logging for observability
    • Refactoring data storage and access patterns
    • Ensuring backward compatibility and data migration strategies
    • Documenting refactoring decisions and outcomes