Sitemap
Vetharsana Thangarajah

Vetharsana Thangarajah

I am Computer Science graduate, worked as an Associate Software Engineer - Java at Virtusa for 3 years. looking for a job to continue my career in Canada.

Microservice

Best Practices

2 min readJul 19, 2022

--

It helps the developers to create good and secure system.

Design

  • should be domain driven design
  • Make service independent.
  • Better go with new design.

Hard coded values

  • Most of developers use hardcoding (Host name or IP address) when one service(A) invoke another service(B). Now A knows where B is.
  • if network team change the hostname or Ip address, we need to change the code and deploy it or need to do other deployment. To avoid this issues we can use service discovery mechanisms to discover second service.

Logging

  • Log twice error — Best practice would be if something is fail just come back immediately and don’t log.
  • Need to log only once and make sure you don’t lose any information.
  • we can use a log appender to write correlation Id or the Id you generated(Eg:001) to your log file among with the log statement.
  • make sure you log debug warned error info in a separate part to make it sense.

Versioning

  • semantic versioning — It is a good thing to get practice of versioning numbers. If someone see the version number they may know when we call the version where whether we have possibility to break it or not...
  • Force upgrade — If you have service A , It calls service B and we need to update B now. When updating, the service request will be different. so when push the new version of service B, service A will break.

So, increment a major version number and deploy it as a separate service. Now you have a B service version 1.00 and B service version 2.00.Therefore our traffic still take to version 1.00.We can talk with consumer and inform about update functionalities and the update date.

Get Vetharsana Thangarajah’s stories in your inbox

Join Medium for free to get updates from this writer.

Authorization & Authentication mechanism

  • Every service try to validate the user where it would get more latencies. As a solution, create a separate identity validation service. Here we have forcefully forwarded to the particular service. we can change validation process or authentication authorization process based on our requirements.

Dependency

  • Should avoid any dependency for our service

Fault Tolerance

  • If there are multiple services, It may failures occur. It is better use a strong fault tolerance mechanism to avoid queues and decrease response time.

Documentation

  • It is important to write document in a technical way for better understanding.

--

--

Vetharsana Thangarajah
Vetharsana Thangarajah

Written by Vetharsana Thangarajah

I am Computer Science graduate, worked as an Associate Software Engineer - Java at Virtusa for 3 years. looking for a job to continue my career in Canada.