Microservices need to honor contracts

opinion
May 25, 20174 mins

In the ever-expanding era of cloud computing, microservices must adhere to contracts

Read the fine print contract agreement
Credit: Thinkstock

“The fox knows many things, but the hedgehog knows one big thing.” Archilochus said in 700 B.C. Centuries later, Unix was developed using similar philosophy: “Do one thing and do it well.”

Derived on the same principles, microservices aim to deliver specific functionality in an independent repeatable way, but any change to that microservice must not result in breaking other services or consumers that it interacts with. Because microservices often invoke other microservices, each must provide a well-defined contract for deployed versions so that any change in the producer microservice will not break the functionality of its consumer counterparts.

There may also be use cases of rolling back consumer microservices that rely on a previous version of producer service, and that brings the discussion how and when code deprecation be done. Importantly, no service should break the versioned contracts unless there are no more consumers with functionality dependent on that specific producer version.

Contracts must be honored

A good microservice implementation must be backward compatible and honoring service contracts must be high on priority. An ideal approach to accomplish this is to follow blue-green deployment model to deploy new microservice code along-side with existing production version code, and teams can test the new code before making it the default production version. This validation model makes the way to get old contracts out of service once every microservice is tested successfully for desired results.

Another option is to have each microservice API have major API version in the URL itself for example, http://myservice/v1 and http://myservice/v2 represent two version of the same service that produce different results.

Cloud-native implementation

One of the foundation premise of microservice architecture is to provide capability to develop and deploy microservices as small, independent but completely functional applications. This architecture has significant benefits—in enabling agile development process, and delivering complex distributed applications. However, microservices do not reduce or eliminate technical complexity but do encapsulate the complexity in a new, distinct wrapper and sometimes add to it.

The pattern requires keeping application logging, security, monitoring, and versioning separate for each microservice and adds development overhead compared to conventional practices. However, it enables a full level of code isolation in a cloud-native way. Each service can be deployed using multiple code versions. For each microservice, one version can be tagged as default serving version or production version. This approach enables various options, including preproduction testing and smoke testing, and it makes rollback operations much simpler.

Design easily, develop efficiently

In a nutshell, microservices aim to reduce complexity via modularization, loose coupling, and contextual bindings. You are in good state with microservices if you can develop independent microservices having version contracts and can release each one independently while maintaining contractual obligations with consumers. A complete implementation of microservice architecture uses the best practices and guidelines for microservice as a contract.

Developing these practices into organization will not only make teams and processes agile but also help your design, development, and testing work to deliver the best performance. Versioning approach not only supports backward compatibility but also allows enough lead time for migrations of consumer apps using the old API version. Apps can also provide feature and permission deprecations based on schedule agreed with the consumer apps, leading to smoother upgrade cycles.

Microservices are the emerging platform architecture that is here to stay, and there are many good reason to support this. The significant advantages provided by microservices architecture such as support and right fit for agile development make it a popular choice to enable develop and rollout quicker releases. Bonding those releases with version contract bindings with other microservices will guarantee the continuous support and availability of stable execution environment throughout the product life cycle.

Vikas Shivpuriya is Technology Director at a large insurance company where he leads product strategy and development. Before this, he was at IBM where he worked on product development for company’s cloud division. At IBM, Vikas was responsible for the development of Cloud platform, information, integration, analytics and deployment, and helped deliver IBM's hybrid cloud application platform capabilities.

With over 18 years in technology world, Vikas is adept at cloud technologies, including PaaS and IaaS, as well as enterprise application integration and related practices. He has been a developer, founding member/partner at a startup, architect, and all around technology leader.

Vikas has been honored with numerous awards including IBM Research accomplishment, invention achievement and Plateau award. He has co-authored five patents and technical papers.

He has keen interest in ubiquitous and pervasive computing, and he is actively involved in cloud and microservices implementations.

The opinions expressed in this blog are those of Vikas Shivpuriya and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author