5 Reasons Why You Need A Microservice Template

Chandan Kumar
3 min readApr 13, 2021

A Microservice template is a code project that can be used to generate a new project whenever you are developing a new microservice, it’s used to save time setting up the project.

1. Reduce setup time

There is always a significant time that takes to setup a new service, setting up the directory structure, the unit testing framework, the code styles etc. Doing all these is fine one time but if you’re creating hundreds such projects you will end up doing same task lot of time and it will eat most of your time.

Also doing it manually may include inconsistencies and potential issues, and also for a big team switching members will make harder for them to understand the project structure if not have in a guaranteed format.

In a monolithic environment this setup time can be considered as negligible because it’s one time activity but for microservice architecture it make sense to have a template for the same.

2. Handling Cross Cutting Concerns

Handling things like logging, metrics, connection to database of message queue could be repeated tasks for your microservices, handling them into the template will make life easy as you just need to spin up the template to do all these things instead of doing the hard work.

These cross cutting requirements are very common in microservice architecture and should be part of all the services, hence handling these in template can save you lot of time and effort, and again you’ll see the consistency in the system so that fixing any issues will not take so much effort.

3. Common Project Structure

First point already discuss this, but I think it should be discussed independently as it a big advantage that we get through these templates.

Having a common template for your services will save you lot of time as the developers need not to understand every different structure of microservices. Once a developer understands a microservice project structure they can easily jump on to other service and can directly starts working over there, and it gives a big advantage.

4. Reduce Dev Machine Setup Time

Defining common steps for services to start locally can again save the dev time, also having something like a run file which can help multiple option to either run the service in development mode or to run the tests can wrap the complexity behind it.

A good service template should contain this.

5. Deployment pipeline/configuration

Deployment can be tedious task in microservice architecture if not done well and in organised manner.

If all the microservices follows different types of configuration for deployment it can be very complex for infra teams to manage all the developments.

Instead if we can have something in common like in service template it can make infra teams life easy to deploy the whole application smoothly and to keep it smooth in future.

Below are few examples for the service templates -

Java

C#

https://github.com/AdrienTorris/aspnet-core-simple-microservices-sample

Python

https://github.com/python-microservices/microservices-template

--

--

Chandan Kumar

Developer at /thoughtworks | Kotlin | NodeJs | ReactJs | Docker | Dev Practices | Agile | Java | Spring Boot | Consultant | Delhi, India | 👨‍💻 📚