Microservices in Java is an architectural style where an application is split into small, independently deployable services, each owning one business capability and its own data. Services talk to each other over the network, usually with HTTP/JSON, gRPC or a message broker, and each can be built, released and scaled on its own. In Java, the most common toolkits are Spring Boot, Quarkus, Micronaut and Helidon.
Microservices trade the simplicity of one deployable unit for team autonomy and independent scaling. That trade only pays off when the system and organisation are large enough to need it.
orders, payments or inventory has a clear boundary, often derived from domain-driven design bounded contexts.| Aspect | Monolith | Microservices |
|---|---|---|
| Deployment | One unit | Many independent units |
| Scaling | Whole application | Per service |
| Data | Usually one shared database | Database per service |
| Failure impact | One bug can affect everything | Faults can be isolated, but network failures multiply |
| Operational cost | Low | High: service discovery, tracing, many pipelines |
| Best for | Small teams, early products | Many teams, clear domains, uneven load |
A well-structured modular monolith is often the better starting point. Split out services when a boundary and a real need, such as separate scaling or release cadence, are clear.
A minimal REST microservice needs one dependency, spring-boot-starter-web, and a controller. This one uses a Java record as the response type.
Package it as a container image (for example with ./mvnw spring-boot:build-image) and run it behind a load balancer. Quarkus and Micronaut offer similar models with faster startup and lower memory use, and both support native images.
Remote calls need timeouts, retries and a fallback. Spring Framework 6 includes RestClient, and Resilience4j supplies circuit breakers.
Always set connect and read timeouts on the underlying HTTP client, and wrap calls in a circuit breaker so a failing dependency does not exhaust your threads. On Java 21 and later, virtual threads make blocking calls cheaper, which suits this style.
Spring Boot is the most widely used and has the largest ecosystem. Quarkus and Micronaut are strong choices when startup time and memory use matter, especially for serverless and native images.
Not technically, but containers and an orchestrator such as Kubernetes make running many services practical, and most teams use them.
Size by business capability and team ownership, not by lines of code. A service should be small enough for one team to understand and own completely.
They avoid distributed transactions. Each service commits locally, and a saga coordinates compensating actions when a later step fails.
Java microservices split a system into independently deployable services that own their data and communicate over APIs or messages. They bring team autonomy and targeted scaling at the cost of network failures, distributed data and heavy operational needs. Start with clear domain boundaries, use a mature framework such as Spring Boot, Quarkus or Micronaut, and invest early in resilience, contract testing and observability.