Microservices-Best Practices For Microservices, Web Application Developers — 4

Upulie Handalage
2 min readJul 17, 2022
Monolithic architecture vs Microservices architecture

This article discusses points about the best practices to follow on microservices/web application development.

  • Make sure the design is fresh and domain driven inside the system
  • As the configuration parameters (such as host name, ip address, url etc.) that are involved are distributed, and thus can be changed by other entities responsible for (for instance network team), it would be challenging. So follow a service discovery mechanism such as a service registry, to discover the other services that a certain service is in communication with. The circuit breaker pattern could be of use in such situations.
  • Having readable yet comprehensive logs (logging the same error from 2 different places is bad practice). Follow the best practice of fail fast, log later. Only log on the final layer. However, make sure you include all the information that enables you to trace back the source. Generate a unique ID (correlation ID) once you hit the top layer so, which enables you to track the service call at any given time. Also, try not to maintain a separate log file, but rather use a separate framework/product (an opensource framework like log stash). Log debug, warning, errors and info in separate levels.
  • Follow semantic versioning which is the governing mechanism to versioning numbering. Bug-fixes, change of functionality with backward compatibility, change of functionality with breaking existing functionality all have their different way of versioning. Follow the force operate concept, which involves providing a time frame to the systems users to shift to a different microservice as the older service will be decommissioned after a given period.
  • Have a separate identity validation service for authorization and authentication mechanisms to reduce communication lag.
  • Avoid dependencies to maintain independence between services.
  • Make executable contracts (by converting the API specification to an executable one) by making the services easy to use. Converting API specification to an executable can be done by preparing test cases, scripts, requests etc. which could be used to evaluate the system.
  • Ensure fault tolerance by failing as soon as possible.
  • Add comprehensive documentation. Use tools like Swagger to write documentation in a technical way. (Swagger compiles a UI as well as proper documentation provided services)

Thanks for reading. Until next time! 👋🏽

References

  1. https://www.youtube.com/watch?v=Alj5sqsv0QU&list=PLD-mYtebG3X9HaZ1T39-aF4ghEtWy9-v3&index=4
  2. https://s7280.pcdn.co/wp-content/uploads/2018/10/microservices-vs-monolithic.jpg.optimal.jpg

--

--

Upulie Handalage

Everything in my point of view. Here for you to read on....