Jasey
Jasey

Reputation: 33

Simple application in Microservices

I am a newbie in Microservices, having theoretical knowledge. I want to make a small application in Microservices. Can anyone please help me with the idea of how to implement microservices? Thanks in Advance!!

Upvotes: 2

Views: 364

Answers (3)

No matter how perfect the code of your microservice is, you may face issues with support and development if the microservice architecture doesn’t work according to certain rules.

The following rules can help you with microservices a lot:

  1. You have to do everything by yourself because you do not have any Rails and architecture out of the box that can be started by one command. Your microservice should load libraries, establish client connections, and be able to release resources if it stops working for any reason.

It means that being in the microservice folder and having made the 'ruby server.rb' command (a file for starting a microservice) we should make the microservice do the following:

Load used gems, vendor libraries (if used), and our own libraries Use the configuration (depend on the environment) for adapters or classes of client connections Establish client connections (permanent connections are meant here). As your microservice should be ready for any shutdowns, you should take care of closing these client connections at such moments. EventMachine and its callback mechanism helps a lot with this. After that your microservice should be loaded and ready for work.

  1. Incapsulate your communication with the services into abstractly named adapters. We name these adapters based on their role (PubSub, SMSMessenger, Mailer, etc.). This way, we can always change the inner implementation of these adapters by replacing the service if the names of our classes are service agnostic.

For example, we almost always use Redis in our application from the very beginning, thus it is also possible to use it as a message bus, so that we don’t have to integrate any other services. However, with the application growth we should think about solutions like RabbitMQ which are more appropriate for cases like ours.

  1. If your code is designed in such a way that your classes are coupled with each other, do it according to the dependency inversion principle. This will help your code to avoid issues with lib booting.

Learn more here

Upvotes: 1

Dina Bogdan
Dina Bogdan

Reputation: 4728

You can create something like a currency conversion app with three microservices like these:

  1. Limit service;
  2. Exchange service;
  3. Currency conversion service.

Limit service and currency conversion service can communicate with the database for retrieving the values of the limits and currencies conversion.

For more info check github.com/in28minutes and look after a microservice repository.

Upvotes: 4

Barkha Agrawal
Barkha Agrawal

Reputation: 1

You can try splitting an existing Monolithic application to gain perspective on microservice architecture.

I wrote this article, which talks about splitting a Django App into microservices. Hope it helps.

Upvotes: 0

Related Questions