Mastering Distributed Architecture: From Microservices to Service Mesh
This article explains the fundamentals of distributed architecture, covering its key characteristics, microservice principles, Spring Cloud implementations, Service Mesh concepts, and essential components like distributed storage, caching, and transaction management for building scalable, resilient backend systems.
Distributed Architecture
Distributed architecture decomposes a system into multiple independent components or services deployed on different nodes, improving scalability, fault tolerance, and flexibility.
Key Characteristics
Distributed: Nodes or servers are spread across a network, forming a distributed environment.
Scalability: Adding nodes increases the system's processing capacity.
Vertical Scaling: Enhancing resources of a single node improves its performance.
High Availability: Multiple replicas, clusters, and load balancing achieve high availability.
Independence: Different services can use different languages, frameworks, and databases, allowing independent development, testing, and deployment.
Typical distributed architectures involve microservices, load balancing, distributed storage, and distributed transactions.
Microservice Architecture
Microservice architecture has six major characteristics:
1. Small Services
Large monolithic applications are split into many small services, each focusing on a specific business function.
2. Independent Processes
Each microservice runs in its own process, enabling independent deployment and scaling, and isolating failures.
3. Lightweight Communication
Services communicate via lightweight mechanisms such as HTTP RESTful APIs or RPC protocols like gRPC, reducing coupling and supporting asynchronous and loosely‑coupled interactions.
4. Business‑Model Driven
Each service is designed around a specific business domain, providing clear boundaries.
5. Independent Deployment
Services can be developed, tested, and deployed independently, allowing rapid iteration and reducing release risk.
6. No Centralized Management
Governance is decentralized, giving teams autonomy to choose technology stacks and processes.
Advantages:
High maintainability – small services are easy to understand and modify.
High scalability – services can be scaled independently.
High fault tolerance – failure of a single service does not crash the whole system.
Disadvantages:
Increased complexity in service communication, data consistency, and distributed transactions.
Operational challenges such as service discovery, monitoring, and log management.
Applicable Scenarios:
Large, complex applications requiring frequent iteration and deployment.
Multi‑team development with clear service responsibilities.
Spring Cloud
Spring Cloud is a widely used framework for building microservice systems in China. It provides common patterns such as service discovery, governance, load balancing, circuit breaking, and configuration management.
Core Features
Service Discovery – dynamic registration and discovery of service instances (e.g., Eureka, Zookeeper).
Service Governance – monitoring, management, statistics, and security control.
Circuit Breaker – prevents cascading failures (e.g., Hystrix).
API Gateway – routing, filtering, security, and monitoring (e.g., Zuul).
Distributed Tracing – observability via Zipkin, Spring Cloud Sleuth, etc.
Spring Cloud Alibaba
Spring Cloud Alibaba integrates Alibaba open‑source components to provide a complete microservice solution.
Nacos: Dynamic service discovery, configuration management, and service management platform.
Sentinel: Flow control and circuit breaking for high‑concurrency stability.
Dubbo: High‑performance Java RPC framework for remote service calls.
RocketMQ: Distributed messaging middleware offering high reliability and throughput.
Service Mesh
Service Mesh is an emerging pattern that adds a dedicated sidecar proxy to each microservice, handling traffic control, circuit breaking, service discovery, and load balancing.
Advantages:
Improved reliability and security of inter‑service communication.
Simplified operations and management of microservice architectures.
Rich observability and control capabilities.
Disadvantages:
Additional complexity and resource overhead.
Steeper learning curve for new tools and concepts.
Distributed Data Storage
Distributed storage spreads data across multiple physical locations or servers, providing sharding, replication, and consistency mechanisms.
Data Sharding: Splits datasets into smaller fragments stored on different nodes, balancing load and improving performance.
Data Replication: Stores copies on multiple nodes to enhance availability and reliability.
Consistency Model: Replicas may be temporarily inconsistent but eventually converge.
Pros:
Scalable and fault‑tolerant storage.
Handles large‑scale data and high‑concurrency requests.
Cons:
Complexity of consistency management.
Distributed Cache
Distributed caches store hot data across multiple nodes to accelerate access; common solutions include Redis and Memcached.
Advantages: Significantly improves data access performance and reduces database load; provides sharding and replication for high availability.
Disadvantages: Requires careful handling of data consistency; cache expiration and eviction strategies add complexity.
Use Cases: Read‑heavy, write‑light applications such as CMS or social platforms, and real‑time data services needing fast responses.
Distributed Transactions
Distributed transactions span multiple independent data stores or service nodes, requiring all operations to succeed or all to roll back.
Two‑Phase Commit (2PC)
Coordinator asks participants to prepare; participants lock resources and respond.
If all are ready, coordinator sends commit; otherwise, it sends rollback.
Three‑Phase Commit (3PC)
Adds a pre‑commit phase to further reduce the risk of inconsistency if the coordinator fails.
Compensation Mechanism
If a local transaction fails, a compensating action rolls back previous operations to maintain consistency.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
