Essential Microservice Architecture Components: From Nginx to Distributed Storage
This article outlines the key building blocks of a microservice architecture—including Nginx as the traffic entry, Spring Cloud Gateway, service registries, Redis caching, MySQL persistence, Elasticsearch, message queues, ELK logging, distributed schedulers, and object storage—explaining their roles, deployment patterns, and common technology choices.
Currently, many companies have adopted microservice architecture; the diagram below briefly summarizes the commonly used components in a microservice design, emphasizing the need for a holistic understanding beyond isolated implementation.
Traffic Entry Nginx
Nginx serves as the external gateway, handling request routing, load balancing, and static‑dynamic separation. It is typically deployed in multiple nodes with keepalived for high availability.
Gateway
Placed after Nginx, the gateway (e.g., Spring Cloud Gateway) provides authentication, routing, protocol conversion, and traffic monitoring. Alternatives such as Zuul, Kong, etc., can be chosen based on their strengths and limitations.
Spring Cloud Gateway also integrates JWT and OAuth2 for token‑based authentication, supporting social logins like WeChat or QQ.
Business Components
These are the individual microservices (e.g., account, order, invoice, checkout) that communicate via Feign, which incorporates Ribbon for client‑side load balancing. Proper service domain modeling may involve DDD.
Service Registry
A registry (e.g., Nacos, Eureka, Zookeeper) is essential for dynamic service discovery. While Eureka is still used, Nacos is recommended for both registration and distributed configuration.
Cache and Distributed Lock
Redis is employed as a cache for hot data and as a distributed lock to solve concurrency issues across nodes. High availability can be achieved with Sentinel or Redis Cluster.
Data Persistence Layer
MySQL is the primary relational database, typically deployed in a master‑slave configuration for read/write separation. As data volume grows, horizontal sharding or database partitioning may be required.
Structured Data Storage
For non‑relational or searchable data, Elasticsearch or MongoDB are used; 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, providing reliable persistence and decoupling.
Log Collection
Logs from distributed nodes are aggregated using the ELK stack: Filebeat collects logs, Logstash processes them, Elasticsearch stores and indexes them, and Kibana provides visualization and search.
Logstash for log ingestion (often preceded by Filebeat).
Elasticsearch for storage and indexing.
Kibana for visual querying.
Task Scheduling Center
Scheduling can be done with Spring’s @Scheduled or Quartz for single‑node setups. Distributed environments use solutions like Elastic‑Job, XXL‑JOB, or Quartz with a shared database, providing high availability and task sharding.
Distributed Object Storage
File uploads are stored in distributed object storage solutions such as MinIO, Alibaba OSS, or FastDFS, enabling scalable and reliable handling of large media files.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
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.