Monolithic vs Microservices Architecture: Advantages, Disadvantages, Gateway Design, Service Registration, and Configuration Center
This article explains the concepts, pros and cons of monolithic and microservice architectures, details the design of API gateways, outlines service registration and discovery mechanisms, and introduces open‑source configuration center solutions for modern backend systems.
Monolithic Architecture
Definition and Characteristics
In early web development, most applications packaged all functional modules into a single WAR and ran them inside one web container, which is called a monolithic (or "giant stone") architecture.
Advantages
Easy development – IDEs support single‑app projects well.
Easy testing – the whole system runs in one process.
Easy deployment – a single package can be copied to a server.
Simple horizontal scaling – add a new node and deploy the same package.
Disadvantages
High maintenance cost as the codebase grows.
Long build and test cycles, reducing developer productivity.
Difficult to upgrade frameworks without rewriting the whole system.
Poor scalability – vertical scaling becomes expensive and horizontal scaling is limited.
Microservices
Definition
Microservice architecture splits business logic into small, loosely‑coupled distributed components, each providing a single responsibility and communicating via lightweight protocols such as HTTP or TCP.
Advantages
System decomposition reduces complexity.
Each service can be owned by an independent team.
Independent deployment and scaling of services.
Disadvantages
Service size limits and the risk of over‑splitting.
Increased coding complexity due to distributed nature.
Data consistency challenges across multiple databases.
Testing a full system becomes more complex.
Changes may affect many services, requiring coordinated updates.
Network latency and bandwidth impact performance.
Typical Architecture Layers
The microservice stack is often divided into six layers: Access Layer, Gateway Layer, Business Service Layer, Support Service Layer, Platform Service Layer, and Infrastructure Layer.
Microservice Gateway
What Is a Service Gateway?
A service gateway combines routing and filter functions, handling request forwarding, authentication, rate‑limiting, logging, and data transformation.
Why Use a Gateway?
It centralizes cross‑cutting concerns such as permission checks, session handling, and security, preventing code duplication across services.
Gateway Design Options
Implement permission checks in every service (high redundancy).
Extract permission logic into a shared service (adds dependency and jar size).
Place permission checks in a gateway filter (lightweight, easy to update).
Core Functions
Routing : forwards external requests to appropriate microservice instances, often using service discovery.
Load Balancing : distributes traffic based on instance load.
Security Authentication : validates identity before forwarding.
Logging : records request details for monitoring and troubleshooting.
Data Transformation : converts client‑specific payloads to a unified format for internal services.
Service Registration and Discovery
Why It Is Needed
In large clusters, services constantly scale up or down; a registration center enables providers to publish their addresses and consumers to discover them dynamically, eliminating manual configuration and supporting load balancing.
Registration Mechanisms
Self‑registration : each instance registers itself on startup.
Third‑party registration : a manager component monitors services and updates the registry (e.g., Eureka).
Discovery Modes
Client‑side discovery : the consumer queries the registry and calls the provider directly.
Proxy (gateway) discovery : the consumer always calls the gateway, which handles registry lookup and routing.
Open‑Source Registries
Eureka (Netflix)
Consul (HashiCorp)
Etcd (CoreOS)
Configuration Center
What and Why
A configuration center centralizes all configuration items, separates config from code, supports real‑time updates, version tracking, and high availability, solving the problems of scattered static files, environment‑specific configs, and lack of auditability.
Key Features
Centralized management and unified standards.
Separation of configuration from applications.
Real‑time push of changes.
High availability and version history.
Open‑Source Solutions
Apollo (Ctrip)
XDiamond (extension of Alibaba Diamond)
QConf (Qihoo 360)
Disconf (multiple Chinese internet companies)
Conclusion
The article compares monolithic and microservice structures, discusses gateway design, service registration/discovery, and distributed configuration centers, and points out further topics such as service monitoring, governance, circuit breaking, and degradation.
IT Architects Alliance
Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.
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.