Microservices Architecture Intro
In the real world, enterprise applications grow too large to fit in a single codebase. If the "Payment" module crashes, it shouldn't take down the "User Profile" module. <strong>Microservices</strong> break a giant app into small, independent services.
The HITEC City IT Park Analogy:
Imagine a single massive building in HITEC City where all companies share the same electricity, water, and elevators. If a pipe bursts in the kitchen of Company A, Company B and C also get flooded and can't work. This is a Monolith.
Instead, the IT park is divided into separate buildings (Microservices). Building A handles Payments. Building B handles Users. They have their own electricity (databases). If Building A catches fire, Building B keeps working. They communicate by sending letters to each other over the road (Network API calls).
- Monolith: One big Spring Boot JAR containing all code and sharing one database.
- Microservices: Multiple small Spring Boot apps. Each has its own database and runs on its own port.
- Spring Cloud Config Server: A centralized server that holds
application.propertiesfor all microservices, so you don't hardcode passwords in every service. - Spring Cloud Release Train: For Spring Boot 3.2/3.3, you must use Spring Cloud
2023.0.x(Leyton). Old Netflix components like Zuul and Ribbon are completely removed.
To build microservices, your parent pom.xml must import the correct Spring Cloud Bill of Materials (BOM).
pom.xml (Parent POM snippet)
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Import the Spring Cloud BOM -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>In a real enterprise app, you would create separate projects: user-service (port 8081) and payment-service (port 8082).
Interview Question: "What are the main advantages and disadvantages of Microservices?"
Answer:
Advantages: Independent deployment (if payment fails, users still log in), independent scaling (scale only payment during a sale), and technology flexibility.
Disadvantages: High complexity (managing 10 servers instead of 1), network latency (services must talk over HTTP instead of in-memory method calls), and distributed debugging is hard.
Enterprise Note: Never start a new project with microservices. Start with a well-structured Monolith. Only break it into microservices when the development team grows too large and the monolith becomes too slow to build/deploy.
Key Takeaways
- ✅ Microservices are independent services with their own databases, communicating via network
- ✅ Spring Cloud BOM (Bill of Materials) manages dependency versions across all services
- ✅ Spring Cloud 2023.0.x (Leyton) is the correct version for Spring Boot 3.x
- ✅ Netflix Zuul, Ribbon, and Hystrix are deprecated — do not use them
Want to track your progress?
Log in to save your place and pick up where you left off.
Progress track karna chahte ho?
Login karo apni progress save karne ke liye aur jahan chhoda tha wahan se shuru karo.
Login