- api-gateway
- discovery-server
- product-service
- inventory-service
- order-service
- notification-service
- k8s
- Schema Flexibility: Allows storing varied product attributes (color, size, specifications, images) without strict schema constraints.
- High Read Performance: Optimized for product browsing and searching with fast querying and indexing.
- Scalability: Scales horizontally to handle large product catalogs efficiently.
- Relational Structure: Ensures ACID-compliant transactions, crucial for inventory and orders.
- Joins & Relationships: Handles relationships between users, products, and transactions effectively.
- Data Integrity & Consistency: Prevents stock inconsistencies and overselling with strict transactional support.
✅ Scalability & Flexibility: NoSQL (MongoDB) for unstructured product data, SQL (MySQL) for structured transactional data. ✅ Performance Optimization: MongoDB for fast product catalog queries, MySQL for transactional integrity. ✅ Consistency vs. Availability: MySQL prioritizes consistency (inventory/orders), MongoDB prioritizes availability (products).
An API Gateway acts as a single entry point for routing client requests to backend services, offering load balancing, security, and monitoring.
- Routing: Directs requests to appropriate microservices.
- Security: Manages authentication & authorization.
- Load Balancing: Distributes requests among instances.
- Rate Limiting: Prevents excessive API usage.
- Monitoring & Logging: Captures request/response data.
- Protocol Translation: Supports REST, WebSocket, and other protocols.
- Authentication & Authorization: Integration with Spring Security or JWT.
- Rate Limiting: Controls request frequency.
- Circuit Breaker: Uses Resilience4j for fault tolerance.
- Service Discovery: Integrates with Eureka for dynamic routing.
- Eureka Server: Acts as a service registry for dynamic service discovery.
- Eureka Client: Registers services and discovers other services dynamically.
- Eliminates hardcoded service URLs.
- Enables dynamic scaling of microservices.
- Improves fault tolerance and resiliency.
Scenario | URL Used in Order Service |
---|---|
Without Eureka | http://localhost:8082/api/inventory |
With Eureka | http://inventory-service/api/inventory |
Key Benefit: With Eureka, service URLs remain unchanged even if the service moves to another port or machine.
- Stores product data efficiently with a flexible schema.
- Optimized for read-heavy operations.
id
name
description
price
- Ensures transactional integrity for inventory stock management.
- Supports relational queries for inventory tracking.
- Guarantees ACID compliance for order transactions.
- Supports complex relationships between users, products, and transactions.
- Circuit Breaker: Prevents system failures by falling back to an alternative method.
- Time Limiter: Ensures time-bound execution.
- Retry Mechanism: Automatically retries failed requests.
- Uses Kafka for event-driven communication.
- Sends order placed events to a
notificationTopic
.
- Enables Prometheus endpoint for monitoring application metrics.
- Exposes system metrics like memory usage, CPU load, and request count.
- Enables circuit breaker health monitoring.
- Configures endpoint exposure for system monitoring.