Engineering the Future of Software
29–31 Oct 2018: Tutorials & Conference
31 Oct–1 Nov 2018: Training
London, UK

Implementing Microservices as Serverless Application

Nikhil Barthwal (Grand Central Tech)
14:1515:05 Monday, 29 October 2018
Location: Blenheim Room - Palace Suite Level: Intermediate
Secondary topics:  Overview, Theoretical

Who is this presentation for?

CTO's, Principal Engineer's

Prerequisite knowledge

- Understanding of Serverless Application Model - Understanding of Microservices Architecture

What you'll learn

- Pro's & Con's of Implementing Microservices as Serverless Application - Details of how to implement various Microservices deployment patterns in Serverless architecture - Understanding of what problem sagas solve and how to implement them in Serverless - Elaborates on some best practices to follow


Microservices architecture uses an assembly of fine grained services to deliver functionality. The goal of this architectural style is to innovate by reducing the dependencies between teams which results in faster code to production.

Serverless Architecture Code is an execution model where server-side logic is run in stateless, event-triggered, ephemeral compute containers that are fully managed by a third-party. It is associated with less management overhead (as there are no servers to maintain) and is cheaper to operate since you only pay for what you use.

While there are similarities and dissimilarities with both architectural styles – one thing that is common is, that both require an application to be composed of a collection of loosely coupled components, which implement business capabilities. Thus, it is possible to implement Microservices architecture as a Serverless Application.

This talk elaborates on this aspect. It covers the advantages & disadvantages of such an implementation and goes into details of implantation of various deployment patterns. It also elaborates upon some best practices to follow.

There are several advantages of using Serverless model for Microservices. For instance, it takes away deployment pains as there are no servers to manage. In fact, for smaller teams, there is no need for a separate DevOps teams. Moreover, Serverless application tends to be extremely efficient in scaling. Moreover, they tend to be cheaper to operate as one only pays for resources that are used.

They also come with their disadvantages. The container ecosystem is very mature and the move to serverless results in loss of flexibility. This leads to vendor lock-in. Further, the developers lose portion of their tooling as deployed functions are hard to monitor or debug. Each deployed function can be subjected to limitation of available resources. In addition, only asynchronous communication is possible between functions.

The talk covers details of various implementation patterns. Typically, real-world services are implemented as multi-tiered services where first tier services often follow a request/response pattern for better error control. Unfortunately, Serverless applications do not support this pattern directly and talk goes into details of workaround for this problem.

Moreover, there is no direct equivalent of central broker like Kafka in Serverless but vendor specific service bus (e.g. Service Bus for Microsoft Azure) can be used with bindings to the functions.

A major issue with Microservices is distributed data management and sagas are used to ensure data consistency across services. The talk covers, how to implement distributed sagas as a protocol for coordinating request among multiple functions.

The talk covers some details on software engineering issues like source code repo design and evolving contracts for microservices implemented as serverless application. It shows examples of how code can be structured in both mono-repo and multi-repo. While mono-repo has the advantage of atomicity of commit leading to easier management of contracts between services although, unfortunately the atomicity of deployment is not available. This leads to a problem when contracts between services change, which creates the need for simultaneous multiple deployment of artifacts. A technique that uses hash of binaries to determine which ones to deploy is discussed.

Furthermore, managing contracts between functions representing services can be tricky. Luckily the availability of libraries like Apache Thrift & Google Protocol buffers can make things easy and the talk goes into details on how to leverage them.

The talk covers some best practices to follow. Particularly, it encourages the use of a unique id attached to every message to gain more visibility during the runtime and to prevent the problem of getting stuck in an infinite loop. Moreover, it emphasizes the need for having a rollback mechanism (which is needed for sagas anyway) and embracing Embrace eventual consistency in designing fault tolerant business processes.

The objective of this talk is to understand the reasons why (or why not) to implement Microservices architecture as a Serverless application and to enable the developer to navigate through the pitfalls during the implementation stage.

Photo of Nikhil Barthwal

Nikhil Barthwal

Grand Central Tech

Nikhil Barthwal is a Senior Software Engineer and a Start-up mentor. He has several years of work experience with both big companies & smaller startups and also acts as a mentor to several startups. He is particularly fond of using Functional programming languages for better productivity.

Outside work, he speaks at local meetups as well as international conferences on several topics related to Distributed systems & Programming Languages.

Leave a Comment or Question

Help us make this conference the best it can be for you. Have questions you'd like this speaker to address? Suggestions for issues that deserve extra attention? Feedback that you'd like to share with the speaker and other attendees?

Join the conversation here (requires login)