Serverless Microservices Architecure in practice part 1

Ehsan Amini
4 min readMar 2, 2020

--

In recent years the benefit of Microservices or Microservices architecture is propelling software designers and software Architects to use it in their software Projects. This article aims to provide an overview of the microservices and also see how we can use this style of software design along with Serverless components and services to gain the maximum benefit of both.

What is Microservice Architecture?

There is no exact and formal definition of microservices architectural style where you can reference, but Martin Fowler and James Lewis have a definition of this term which I found interesting.

The term “Microservice Architecture” has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. While there is no precise definition of this architectural style, there are certain common characteristics around the organization around business capability, automated deployment, intelligence in the endpoints, and decentralized control of languages and data.

James Lewis, Martin Fowler

So if you want to design and run your software using this style, you need to have some common characteristics for architecture in your design.

Advantages of Microservices

Microservices are often contrasted against monolithic architecture. Monolithic architecture is the classic way of building an application.

Isolated points of failure: Because the application is divided up, one part of the application breaking or crashing does not necessarily affect the rest of the application

Autonomous scalability: Instead of scaling the entire application, only the microservices that receive a great deal of usage can be scaled

Faster value delivery: Features can be rolled out or updated one at a time, instead of updating the entire application stack

Tech Flexibility: Microservices can be written in different languages and each has its libraries.

Independent modules: each service is designed, deployed and run separately from the other services and can have its database.

What is Serverless computing?

The computing world has changed forever with the advent of the cloud. Cloud gives developers access to infrastructure instantly, cheaply, and at nearly infinite scales. The agility of cloud and high availability and constant agility demands of modern business have strained monolithic architectures and resulted in the rise of microservices-based applications.

Serverless computing enables developers to build applications faster by eliminating the need for them to manage infrastructure. With serverless applications, the cloud service provider automatically provisions, scales, and manages the infrastructure required to run the code.

Serverless microservices in Azure
The microservices can be part of serverless architecture, hosted in containers or using Microsoft Azure functions (FaaS). Azure functions are available in Microsoft Azure and you can use them to build a microservice faster that can be scaled automatically and you pay only when you use the service.

A combination of Azure functions and microservices architecture design makes an incredible and flexible environment for developers and architects. A function is a relatively small bit of code that performs only one action in response to an event. Depending on how developers have divided up an application, a microservice may be equivalent to a function (meaning it performs only one action), or it may be made up of multiple functions.

E-Scooter Management platform
One of my favorite use-cases to use serverless microservices architecture is a platform for managing electronic Scooters that you have seen these days in the city. As this business is growing so fast, the need for a standard and global platform that can manage the entire workflow is needed more than before.

in my scenario i am using only as an example the photo of Voi Scooters company.

voi e-scooter

This platform can be used by many scooter suppliers and companies and also the e-scooter service providers in big cities.

Using a central and standard platform can reduce the provider’s operation costs.

User Scenario:
To be able to use an e-scooter, first, you need to download a mobile application and register there. I’m using Azure Active Directory B2C where all the user sign-up, sign-in, reset password and authentications will be managed out of the mobile application. It’s also possible to build custom policies and custom flows to build complex sign-in and sign-up scenarios and also integrating the other social identity providers like Twitter, Facebook and …

After registration, you should add a payment method (Paypal, credit card,…) to your account.

So, now you are ready to use the App and first you have to find a scooter using scooter finder which shows all available scooters near you and shows their location of the map. Each scooter has a barcode or QR code. You can scan the code within the app and select the start button and start the ride. When you reach your destination you have to find a proper place to park the scooter (you can lock the scooter and finish the ride only inside the predefined areas and locations) and lock it.

The app asks you to take a picture of the scooter to be sure it’s parked correctly and to have a picture of it. This can be done within the app using your smartphone camera. The application will calculate the ride costs depends on the time and fees and book the amount to the payment method you provided before.

Software Architecture:
So let’s see what is happening behind the scene. What kind of software architecture can be used to cover this business scenario?

Continue in part 2…

--

--