DEV Community

Discussion on: How to do microservices?

Collapse
jamesmh profile image
James Hickey • Edited on

For a really basic implementation that should be OK.

Usually, though, each microservice will publish some client (as a package/library) that the other services will use.

As far as caching, yes - HTTP is a good start. You could play around with Redis etc. also. But many times HTTP does the trick and is nice because it's just built-into the protocol you are using.

Also, consider that each service should define it's own view components. So just like each service exposes a client, they would expose some view library also (there are many ways to do that depending on the language, framework, etc.)

It's hard stuff!

I personally am a fan of an approach mentioned by Udi Dahan's which is to make everything run in the same run-time. But that's another topic for another day 😜 Check this out as a primer if interested done by Simon Brown

Collapse
alejandro profile image
Alejandro Author

Thank you very much for your answer, I was wondering if I was missing a piece of technology on the stack but as far I can see the communication to the services can be done through http requests.

Collapse
jamesmh profile image
James Hickey • Edited on

Yes - just using HTTP works fine. You will find that microservices which are built with statically typed languages - like Java or C# - will typically expose client libraries as I had mentioned.

That way, any specific service doesn't need to know the url to another service and all the parameters, etc. They can just use the client which acts as a contract for accessing it.

But using HTTP calls directly in code like you're doing is OK for smaller projects. But then, microservice aren't really useful for smaller projects... lol

Other issues that come up are service discovery (usually services don't have a hard-coded IP or machine name and are on a local network vs being exposed on public urls), dealing with failures (when service A is down and service B is trying to call it - what should it do?), using a pub/sub or message bus, etc.