https://blog.yourkarma.com/building-microservices-at-karma
Interesting questions in comments:
How do you handle service to service authentication and authorisation when backend services need to talk to each other?
To what extent do you try and replicate production on a local machine for production? What does your inner development and testing loop look like?
Question: I'm curious about the database layer. Do all of the individual services talk to the same datastore and share access to the same objects? For example does the shipping service just read addresses from the users datastore in order to know where to ship to? If so do the services share a library (gem) that provides models? My inclination is to make a separation at the data layer as well however that can be a bit tricky especially with user related data.
Answer: We separate the data layer too. Each service has its own database (or none at all). Each microservice chooses what to expose. The same principle applies as in object oriented programming: data is private and exposure is minimal.
We use the gem Faraday to connect to other microservices. We don't try to let the data behave like ActiveRecord. We sometimes apply the repository pattern, but since microservices are often small and simple, we usually don't bother. We've released a gem with some extra plugins for Faraday here: https://github.com/yourkarma/f...
About sharing data: we try not to have every service having to connect to get user related data. So we need to give the shipment information all the information it needs, because it will not ask for any data by itself.