Overview of Common Components in a Microservice Architecture
This article provides a comprehensive overview of typical microservice architecture components—including Nginx as the traffic entry, Spring Cloud Gateway, service registries, Redis caching and distributed locks, MySQL and Elasticsearch persistence, message queues, log collection, task scheduling, and distributed object storage—highlighting their roles, deployment patterns, and best‑practice considerations.
Introduction
Microservice architecture has been widely adopted in many companies; this article summarizes the most commonly used components in a typical microservice design, helping developers gain a holistic understanding beyond isolated implementation details.
Traffic Entry Nginx
Nginx serves as the external gateway, handling request routing, load balancing, and static‑dynamic separation. It is usually deployed in multiple nodes with keepalived for high availability.
Gateway
Behind Nginx, a gateway such as Spring Cloud Gateway provides authentication, routing, protocol conversion, and traffic monitoring. Alternatives like Zuul, Kong, etc., can be chosen based on their strengths and limitations.
Business Components
After the gateway, business services (e.g., account, order, invoice, checkout) are split into independent microservices. Inter‑service HTTP calls use Feign, which integrates Ribbon for client‑side load balancing. Proper domain‑driven design is essential for service boundaries.
Service Registry
A service registry (e.g., Zookeeper, Eureka, Nacos) is required for dynamic service discovery. While Eureka is still used in some legacy systems, Nacos is recommended for both registration and distributed configuration.
Cache and Distributed Lock
Redis is employed as a cache to accelerate hot‑data access and also provides distributed lock capabilities to solve concurrency issues across multiple nodes. High availability can be achieved with Sentinel or Redis Cluster.
Data Persistence Layer
MySQL is the typical relational database, often deployed in master‑slave mode with read‑write separation. When data volume grows, horizontal sharding (both vertical and horizontal) may be needed.
Structured Data Storage
For non‑relational or JSON‑like data, Elasticsearch or MongoDB are preferred; Elasticsearch offers powerful DSL queries and even GIS capabilities.
Message Middleware
Asynchronous communication between services is handled by message queues such as RabbitMQ or RocketMQ, ensuring reliable message delivery and decoupling.
Log Collection
Log aggregation is achieved with the ELK stack: Filebeat collects logs, Logstash transforms them, Elasticsearch stores them, and Kibana provides searchable visualizations.
Task Scheduling Center
Distributed scheduling can be implemented with Quartz (via database), Elastic‑Job, or XXL‑JOB, offering high availability and task sharding.
Distributed Object Storage
File uploads are stored using distributed object storage solutions like MinIO, Alibaba OSS, or FastDFS, which support high‑throughput and scalable storage.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
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.