Best practices for micro service design
We all know that micro services are very hot into the market, it’s because they provide a high performance and modern infrastructure so that we can scale our business infinitely. but the question comes what is the best ways what could be the best strategies through which we can design a scalable micro service.
Today I’ll talk about few of the important key consideration which we should follow up whenever we are designing any micro service. Talk about important points important takeaways which will help us to create a robust and secure micro service. Below are some of the important points which will help us to create a Greek micro service design .
- Lightweight: this is one of the very important key characteristic of any micro service. lightweight means your application should be lightweight in size. whatever programming language you are choosing for your microservice the ultimate goal is you should package(I mean build package) should be lightweight. Below are some of the key advantage of keeping your packages lightweight
- your application will be up very quickly
- whenever you will scale your Micro service there could be more than one version of the same microservice Is running together in order to handle the workload of your product. if you have the lightweight package it will definitely help to bring more version of applications in lesser time.
- similarly if the loads get decreased you don’t want skilled infrastructure should still be in picture and it keeps the burning cost if your package is lightweight it will be easier to release that infrastructure and scale down your application with lesser infrastructure
- Independent deployable: This is the next important characteristic of any micro service that you can develop the feature of that microservice independently and also you can deploy the microservice onto the server independently. below are some of the advantages it will provide
- None of the any other microservice will get impacted by this deployment. I mean this will help us to keep our own microservice up to date as always.
- It will lesser time to test the feature of a micro service
- you’re sure that at least your application is working perfectly fine within your environment. although there is always a chance of integration testing altogether to verify whether overall that application is working or not but at least from release perspective it’s quite important that your microservice should crew and use the newest feature within it without having any dependency of any other microservice.
- independently scalable: The beauty of the microservices are they can be independently scalable they can automatically scale up /scale down if the load related to that microservice increases. At the above topic we have already talked about that if the package size will be lightweight it will really help us to achieve this objective. Below are some of the key advantage of using this independently scalable feature.
- low infrastructure cost (pay as you use instead of running the largest infrastructure always up even the load is not too high)
- You can manage the configuration settings forest scalability on varies environments very easily for example in the dev environment you can test with one or two replicas in staging you can test with five replicas and in production you can set up to ten replicas. all configurations can be done quite easily depending on each environment.
- Resiliency: we all know that in microservice world more than one microservices communicate together to fulfill the customers request. the more microservices the more communication between them. in case of any problem while doing the communication from one microservice to another microservice it’s quite important that resiliency should be built in. there are two men techniques you can apply towards your micro service to make it more resilient.
- Retry mechanism: if you are trying to get some data from your downstream or from your upstream you might not always get the intended result. there could be some network problem connectivity issue scaling issue there are multiple factors which might lead that your data is not being received from upstream or downstream. in such scenarios whenever you are calling any API calls from your application it’s quite important that we should always use the retry mechanism.
- Health check: he should always integrate health check with each of the microservice this will help us to debug if any micro service is not healthy at any moment.
- Fault tolerance : in case you are not receiving the Internet result from your microservice there must be a second layer of strategy how you’re going to handle that scenario fault tolerance talks about that. it’s always important to keep fault tolerance included while doing the code of the feature itself.
- Logging and Tracing: you should always use correct logs and tracing capabilities while implementing a micro service or while designing a microservice. correct logging tracing mechanism will lead us various advantages for example
- you may know about the issues in advance
- you may fix the issue very quickly
- you can dig deeper into the flow with the help of your trace IDs
- Security: this is another very important key consideration for any microservice design. security must be in place during the design of your microservice it’s not something which you will rely at the time of coding. there are various techniques to secure your microservice for example
- Authentication: you must authenticate each request before serving
- Authorization: you must validate whether this user has a permission to use this feature or not
there are multiple ways to ensure the security of your microservice for example jwt tokens using any external API monitoring tools for example apigee or using any API gateway which will handle your API request and do all the security checks on top of it
hope you have find it helpful for your next design consideration I’ll happy to take your inputs on any microservice design or help you to design your own solution