An Introduction to Service and Microservice-Oriented Architectures: A Full-Stack Developer’s Perspective

Microservices

According to Red Hat senior principal product manager Mark Little:

"Microservices and SOA projects have seen massive growth over the past 5+ years. Surveys indicate as many as 75% of organizations are now using or planning to use microservices."

This growth underscores the importance of having a technical understanding of microservices, service-oriented architecture approaches, their implications, and when each might make sense.

As a full-stack developer who has worked on systems leveraging both styles, I’ll provide perspective into their key characteristics, where they differ, tradeoffs and considerations for usage.

Diving Deeper on The Differences from SOA

Let‘s expand on some key ways microservices diverge from traditional service-oriented architectures:

Decentralized Governance

Microservice teams own all aspects of particular services. They choose standards, select supporting technologies/patterns and evolve the service independently. SOA centralizes many standards across teams under enterprise architecture.

Decentralized Data Management

Data consistency between microservices is eventually consistent and transactions across services are avoided. SOA generally relies on transactional consistency between services sharing a common database.

Fault Tolerance

Microservices implement robust resiliency patterns as they expect failures between services. While SOA services handle errors, systems aren‘t fundamentally designed for constant failure as microservices are.

Componentization

Microservice components are modeled around domain-driven design and strategic pattens like bounded contexts. SOA components come from object-oriented decomposition approaches.

To demonstrate these differences, let’s compare a traditional 3-tier, SOA e-commerce app to a microservices version:

Monolithic, 3-Tier SOA App

  • Tightly coupled across layers
  • Shared databases
  • Synchronous communication
  • Enterprise architectural standards

Microservices Version

  • Loosely coupled
  • Independent data
  • Async messaging
  • Decentralized – teams choose own standards

Development practices also diverge. SOA favors enterprise architecture planning for standardization. Microservices embrace Agile methods, decentralized teams, and rapid experimentation.

So in summary, while both SOA and microservices orient around services, microservices take a vastly more decentralized, Agile and fault-tolerant approach.

Microservice Architecture Patterns & Best Practices

As an architecture style, microservices leave many implementation details open. Over the past decade, common patterns and best practices have emerged:

API Gateways – Façade to decouple clients from services, handle routing, authentication, monitoring, and resiliency patterns.

Service Meshes – Manage service-to-service authentication, encryption, traceability, failure handling, and observability without code changes. Popular options include Istio and Linkerd.

Configuration Servers – Centralize external configuration management for services to control behavior without redeployment.

Containerization – Containers (i.e. Docker) provide isolated environments to consistently run services and model infrastructure.

Domain-Driven Design – Strategically model microservice boundaries and interactions around domains rather than technical capabilities.

Infrastructure Automation – Script installation, configuration, scaling and inter-service communication through Infrastructure-as-Code tools like Ansible, Terraform, and CloudFormation.

These and other patterns help tame the complexity of microservices at scale.

Microservices Pros & Cons Revisited

Taking a deeper look at the tradeoffs:

Pros

Faster Feature Delivery

A 2021 survey found teams using microservice architecture release features on average 33% faster compared to monolithic teams. Rapid iterations compound making microservices ideal for innovative domains.

Small service codebases also require less effort to change. This allows teams to take on more ambitious projects knowing that future change won‘t require as much effort.

Painless Scalability

Microservices enable incremental horizontal scaling. Need 50% more capacity for an e-commerce app‘s payment processing? Simply run more instances of that singular service. Contrast this to scaling a monolith which requires replicating the entire application stack.

Services also scale developer productivity. Smaller codebases relieve cognitive strain. Adding developers to a specific service is simpler than understanding all parts of a complex monolithic codebase.

Resilience by Design

Limiting synchronous calls and transactions between services increases overall system resilience. Even if a few services fail, requests can be isolated, contained or gracefully handled through patterns like circuit breakers. Monoliths lack this degree of fault isolation.

Technology Flexibility

Microservice teams can pick fitting technologies for their specific domain challenges. For example, machine learning services might use Python while customer-facing services could leverage JavaScript frameworks. This caters to specialized skill sets and avoids standardized tech drawbacks across a monolith.

Cons

Operational Complexity

A 2021 State of Software Delivery report found 75% of organizations cited operational complexity as a top microservices concern:

Managing and monitoring dynamic microservices environments requires new approaches compared to monolithic apps. Teams must plan automated infrastructure, visibility tools, and failure handling to tame complexity.

More Cross-Team Coordination

While decentralized data ownership avoids integration issues of SOA, calls between microservices for business transactions still require coordination. Changes impacting service contracts need communication across teams. Conways‘ Law suggests microservice team structures may require rethinking as well.

Refactoring Database Schemas

Evolving data models when each service owns its data requires careful versioning and transition planning. Simple schema changes now impact multiple code repos and teams instead of being centralized.

Increased Focus on Testing

With distributed services, end-to-end functional testing is vital for confidence. Stubbed unit testing isn’t enough. This demands more test automation, mocks, performance testing, and integration testing across the growing surface area of microservices.

When Should Teams Move to Microservices?

With the differences from SOA clearer and both styles‘ tradeoffs outlined, when should teams take on refactoring monoliths?

Common Inflection Points

Here are signals it may be time for microservices:

  • Features take too long to build and release
  • Developers spend excessive time understanding/navigating complex codebases
  • Scaling requires continually buying larger machines
  • Reliability issues plague production
  • Customers request innovative features difficult to build given tech constraints

Strategies for Incremental Migration

Ripping out and replacing functioning monoliths carries risk. Organizations like Amazon, Netflix, and Uber took an incremental "strangler pattern" approach:

  1. Prevent monolith growth by building new features as microservices.
  2. As business requests come in, determine if shifting existing monolith functionality to a microservice makes sense.
  3. "Strangle" legacy functionality over time by routing traffic to new microservices vs the old system.
  4. As legacy code is reused less, simplify then retire it.

This reduces risk of business disruption while working towards microservices end-state.

Migrations also often reveal ideal microservice boundaries different from both SOA and existing app segmentations. Experimentation here is key through methods like domain-driven design.

Closing Summary

As Mark Little of Red Hat noted earlier regarding the growth in microservices and SOA, the implications of these architectural styles continue to expand.

Their decentralized, distributed nature contrasts greatly with traditional centralized, monolithic styles – enabling unprecedented velocity, reliability and scaling when applied effectively.

However, microservices also introduce daunting operational and organizational complexity. Their fit depends greatly on application characteristics and team capabilities.

For organizations willing to undertake the migration journey, microservices offer a path to sustainably innovative and resilient software delivery. But it requires embracing fundamental change – organizationally and technologically. The outcomes can be transformative.

Similar Posts