Mastering Microservice Architecture: Key Components and Best Practices

This article provides a comprehensive overview of a typical microservice architecture, detailing the roles of Nginx as the traffic entry, gateways, business services, service registries, caching, databases, messaging, logging, scheduling, and distributed storage, and offering practical guidance for high‑availability deployment.

Architect
Architect
Architect
Mastering Microservice Architecture: Key Components and Best Practices

Introduction

Microservice architecture has become mainstream in many companies, yet developers often lack a holistic view of the entire stack. This guide presents a concise diagram of the most common components and explains their responsibilities and best‑practice deployment patterns.

Traffic Entry – Nginx

Nginx serves as the external gateway, handling request routing, load balancing, and static‑dynamic separation. For high availability, multiple Nginx nodes are deployed together with keepalived to provide failover.

Gateway

Behind Nginx, a gateway (commonly Spring Cloud Gateway) performs authentication, routing, protocol conversion, and traffic monitoring. Alternatives such as Zuul 1, Zuul 2, and Kong are mentioned, each with its own trade‑offs.

Business Services

After the gateway, the system consists of individual microservices (e.g., account, order, invoice, cashier). Services communicate via Feign, which integrates Ribbon for client‑side load balancing. Proper domain boundaries can be designed using DDD principles.

Service Registry

A registry (e.g., Eureka, Zookeeper, Nacos) is essential for dynamic service discovery. While the current platform uses Eureka, Nacos is recommended for new projects because it also provides distributed configuration management.

Cache and Distributed Lock

Redis is used both as a cache for hot data and as a distributed lock provider. High availability is achieved with Sentinel (one master, two slaves, plus three sentinel nodes) or Redis Cluster for scaling beyond a single node.

Data Persistence Layer

MySQL is the primary relational database, deployed in a master‑slave configuration to enable read/write separation. When a single table becomes a bottleneck, horizontal (sharding) and vertical partitioning are considered, though most enterprises do not reach that scale.

Structured Data Storage

For non‑relational or search‑heavy scenarios, Elasticsearch or MongoDB are used. Elasticsearch offers rich DSL queries, including full‑text and GIS search, making it suitable for analytics and retrieval‑intensive workloads.

Message Middleware

Synchronous calls use Feign, while asynchronous decoupling relies on message queues such as RabbitMQ or RocketMQ to ensure reliable, persisted messaging.

Log Collection

Filebeat collects logs from each node.

Logstash transforms and forwards logs to Elasticsearch.

Kibana provides visualization and keyword‑based search.

Task Scheduling Center

For scheduled jobs, single‑node applications use Spring’s @Scheduled or Quartz. Distributed environments adopt Quartz with a shared database, Elastic‑Job (Zookeeper‑based), or XXL‑JOB, which abstracts scheduling logic from business code.

Distributed Object Storage

File uploads are stored in distributed object stores such as MinIO (high‑performance, Go‑based), Alibaba OSS (commercial), or FastDFS (lightweight open‑source). These solutions avoid storing large files on individual service nodes.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed SystemsBackend ArchitectureMicroservicesNGINXSpring Cloudservice registry
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.