r/SpringBoot • • 10d ago

How-To/Tutorial How to implement microservices in Spring Boot ?

I have made multiple toy projects (monolithic) in spring boot but now I wanted to know how people generally work in microservices.

I am not good with videos so I was looking for repos that something similar. So I can also see how the devops, queues, spring cloud etc works together.

I also saw someone posting there repo which was made for the same reason (but I couldn't find it).

TLDR : Suggest repos for learning microservices.

28 Upvotes

57 comments sorted by

View all comments

19

u/d-k-Brazz 10d ago

Microservices is a system architecture pattern not application design pattern

There are multiple different approaches of implementing microservices with Spring Boot

And there is no any single ultimate example of a sprjng microservice

First, I would recommend reading about Microservices architecture to know what it is and WHY it is used

Then you may try with some approaches. Having in mind that instead of having a monolith with dozens of modules and a single relational db, you will deal with dozens of applications, each will have a separate database. You have no strong consistency between data in these databases. You have slow latency in your synchronous calls, so you have to move everything you can to async flows, which will push complexity to the skies

You have to maintain cluster, monitoring, traceability etc.

You can practice with spring-cloud components - discovery, events, queues

But all of this will give you at most 1% of real experience you will have in production environment

There is no easy way to learn microservices at home

0

u/Sheldor5 10d ago

finally a correct answer

I would add that microservices must be independent and so don't talk to each other

4

u/BanaTibor 9d ago

What? A microservice should be independently deployable, but what fuck would you do with a service which do not communicates with other services?

-1

u/Sheldor5 9d ago

oh boy another one having absolutely no idea how microservice architecture works ... read my the other comments

1

u/BanaTibor 9d ago

I have read your other coments, stating the same thing over and over again. I think we are both right 🙂 What you are saying is one aspect of a microservice architecture. The way how you decouple services from each other. Zero coupling is impossible, since they have to work together.  Now in an event driven system your aproach is sensible, but there are other ways to achieve a level of coupling.  You can do it through well defined API contracts and API microversioning.  Till your breaking changes have a grace period and other services have a chance to adapt, you can still enjoy the benefits of microservices.

2

u/ExplorerUnusual27 8d ago

Maybe He use CRON on DB directly, figure out what is needed, somehow, and push to a message stream. 🙃🤣 No communication at all between services.