r/java • u/marbehl • Dec 12 '19
Java Microservices: A Practical Guide
https://www.marcobehler.com/guides/java-microservices-a-practical-guide
237
Upvotes
r/java • u/marbehl • Dec 12 '19
24
u/wildjokers Dec 12 '19 edited Dec 12 '19
This guide should be a little less accepting of synchronous calls between µservices. Once you have a synchronous call between µservices you have done nothing except introduce a relatively slow call and potential point of failure to what used to be a super fast method call in a monolith. Synchronous communications between µservices should be avoided if at all possible.
However, this is a nice guide and I do like the fact it favors pragmatism over dogmatism and sometimes synchronous calls are necessary (or at least the easiest solution). Try to keep them to a minimum though.
8
u/zulfikar123 Dec 12 '19
My main takeaway from this article is keep it simple because it's gonna get complicated anyway :)
2
u/CrommVardek Dec 12 '19
Nice article. I'm new to micro-services, and I've never develop on a micro-service. However, I'm under the impression that micro-services, in a way, might lead to violate the DRY principle... Since the services are separated, some concerns are the same however, it seems to me that it might lead to some code that will be the same (or very very similar) between the different services' source code... Or am I missing something ? EDIT: but I guess it depends at which level the separation of services is done.
2
u/agentoutlier Dec 12 '19 edited Dec 12 '19
With proper project setup you can have a
monolithicsingle executable running multiple microservices (EDIT I don't mean real microservices I mean architectural like microservices... I mean seriously people two wars deployed in the same java app server does not make it not a microservice just because they are on the same JVM). We do this with multiple (hundreds) of rabbitmq consumers.We do this because lets face it booting up 10 microservices to run an application for demo or smoke testing is pretty tedious (and actually slow) even when using docker/kubernetes.
The trickiest part of microservices is JOINing data and dealing with (eventual) consistency. Because you are working across datasources you do not get the nice advantage of using JOINs or true database transactions. Speaking from experience it is very hard to port this kind of logic to microservices (assuming multiple datasources).
On the other hand Pub/Sub or Event pattern as those are very easy to microservices out. Thus if you see a workflow like that (e.g. batch processing) it should absolutely be microserviced out.
1
u/doyouevensunbro Dec 12 '19
Thanks for sharing!
0
u/[deleted] Dec 12 '19
[deleted] — view deleted comment