Compartilhar via


Thoughts on Microservices

Based on various readings/research I've done recently, I decided to summarize my understanding of Microservices. For the most part, this is platform-neutral:

  • Microservices can be considered ‘fine-grained SOA’ – a small self-contained service that does not depend on other microservices.
  • These services are mostly composed and orchestrated together to form more complex application services.
  • Typically small feature-focused teams will create these microservices.
  • Each team is free to use any technology/stack that makes them productive. Each microservice can use different versions of frameworks/platforms.
  • DevOps mentality means each team is also responsible for deploying the microservice into production and monitoring and managing it.
  • Have a self-service capability that allows teams to ‘spin-up’ a service to test/develop ideas. (this is where the private Paas/cloud helps).
  • Organization structure should be built around this idea of microservices – it should not be some huge team but a number of small independent teams.
  • Once a service is out there, it never goes away. You can put new versions side-by-side and redirect calls to the new version, but the old version remains around. If there is an issue with the new version, traffic is routed back to the old version (automatically or manually).
  • Microservices are cornerstone of the system so they should be very, very, very well tested. Try to break it before publishing it to production.
  • All deployment, management is done through script … no manual process.
  • De-normalize all data so that it can be sharded as much as possible.
  • Preferably these services should be stateless but this can be tricky. Azure Service Fabric allows you to build statefull microservices with no downside.
  • Every service should have a client access library – do not require apps to call your service via REST endpoint as different interpretations of the methods etc. may cause confusion.
  • Because microservices get called so often, consider using a binary format like Google Protocol Buffer, instead of JSON. This will reduce network congestion and improve performance.
  • Tooling is the secret sauce that makes microservices viable in the enterprise. There are some open source tools but you will have to build many of your own because:
    • Microservices are complex to build and compose.
    • Avoid duplicate code everywhere.
    • Versioning is not easy.
    • Same with routing.
    • Common interface naming requires some sort of repository.
    • Monitoring and logging should be inherent (not a separate microservice).
  • A good PaaS system makes some of these issues go away and adds autoscaling, service discovery, versioning, rollback, fault tolerance etc.