Serverless - API Architecture Style Every Developer Must Know

Serverless architecture is an approach to software design that allows developers to build and run services without having to manage the underlying infrastructure. Developers can write and deploy code, while a cloud provider provisions servers to run their applications, databases, and storage systems at any scale.

Serverless architectures are application designs that incorporate third-party “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform. By using these ideas, and related ones like single-page applications, such architectures remove much of the need for a traditional always-on server component. Serverless architectures may benefit from significantly reduced operational cost, complexity, and engineering lead time, at a cost of increased reliance on vendor dependencies and comparatively immature supporting services.

serverless architecture

What Is Serverless?

Serverless is an application delivery model where cloud providers automatically intercept user requests and computing events to dynamically allocate and scale compute resources, allowing you to run applications without having to provision, configure, manage, or maintain server infrastructure.

Serverless allows applications to be hostless (apps aren’t hosted on a server), stateless (interactions and data aren’t stored), elastic (resources are scaled up and down without limits), distributed (multiple services are linked for seamless functioning), and event-driven (resources are allocated only when triggered by an event).

Serverless Model – 

  • The developer builds an application that includes a function that will determine how the application responds to a particular user action. Typically, cloud providers offer pre-packaged FaaS products to simplify coding for developers and bring in pre-built backend elements.
  • An event is defined that specifies how and when the function will be triggered. For example, when the user initiates an HTTP request, the application may want to fetch and deliver certain data. This “if-then” process is called an event.
  • Once the application is deployed and accessible to the user, the event is triggered through a user action.
  • The application relays the event to the cloud provider, and the provider dynamically allocates the resources necessary to respond to the action as per the predefined function.
  • The user receives the data or any other result as defined by the function.

Importantly, when there is no user request, zero resources will be allocated, and no data is stored in an intermediary state. This ensures that only the newest and recently updated data reaches the user (making your apps real-time) and saves storage costs.

Why use serverless architectures?

By using a serverless architecture, your developers can focus on their core product instead of worrying about managing and operating servers or runtimes, either in the cloud or on-premises. This reduced overhead lets developers reclaim time and energy that can be spent on developing great products which scale and that are reliable.

Servers allow users to communicate with an application and access its business logic, but managing servers takes considerable time and resources. Teams have to maintain the server hardware, take care of software and security updates, and create backups in case of failure. By adopting serverless architecture, developers can offload these responsibilities to a third-party provider, enabling them to focus on writing application code.

One of the most popular serverless architectures is Function as a Service (FaaS), where developers write their application code as a set of discrete functions. Each function will perform a specific task when triggered by an event, such as an incoming email or an HTTP request. After the customary stages of testing, developers then deploy their functions, along with their triggers, to a cloud provider account. When a function is invoked, the cloud provider either executes the function on a running server, or, if there is no server currently running, it spins up a new server to execute the function. This execution process is abstracted away from the view of developers, who focus on writing and deploying the application code.

 

Function as a Service (FaaS), a popular type of serverless architecture, allows developers to focus on writing application code.

While serverless architecture has been around for more than a decade, Amazon introduced the first mainstream FaaS platform, AWS Lambda, in 2014. Currently, a majority of developers still use AWS Lambda to build serverless applications, but Google and Microsoft have their own FaaS offerings as well, called Google Cloud Functions (GCF) and Azure Functions respectively.

Top 4 Applications of Serverless Computing

As you may have gleaned from the examples, serverless computing can be applied in various ways. It drives efficient resource allocation, supports high bandwidth scalability, and delivers dynamic data updates. Here are the four primary applications of serverless:

Top Serverless Applications

1. Smart devices and IoT

Serverless computing is ideal for IoT as it involves short bursts of interaction, where real-time data exchange is mission-critical. Also, IoT environments handle unpredictable volumes of data, which serverless can handle with ease. Finally, IoT functionalities are entirely event-based – either triggered by the environment or the IoT device user. Serverless architecture allows you to connect the IoT hub or gateway to other elements of your connected landscape, such as smartphones, payment gateways, etc. You will also be able to accommodate multiple users for a single IoT touchpoint, as in the case of smart factory equipment.

2. Event-based application scenarios

Applications that rely hugely on user interactions and user-triggered events are prime candidates for serverless. For instance, an e-commerce website could gain significantly from a serverless model, fetching product data, delivery information, payment information, etc., as per current user volumes and requirements. E-commerce traffic also fluctuates across different days of the week and seasons of the year. A serverless architecture means you can quickly scale to cater to a demand uptick and increase your profitability without having those resources lie idle 24/7/365. Similarly, on-demand learning content providers, webinar hosts, etc., can also gain from serverless.

3. Automated system administration

Serverless computing has a wide range of internal applications as well. System administrators responsible for allocating and managing infrastructure services can switch to serverless and reduce manual efforts significantly. For example, Deloitte’s Cloud Managed Services product uses serverless computing to deliver scalable and consistently optimized infrastructure support to its clients. Systems administrators can focus on more value-adding aspects of product delivery, such as new features, security, or cost optimization strategies. The same application can be leveraged by large enterprises to orchestrate cloud resource provisioning across different locations and business units.

4. Elastic performance for CDN

Content delivery networks (CDNs) allow enterprises to deliver high-volume content across distributed locations. CDN processes are extremely resource-intensive, and user expectations can vary dramatically across peak and lull periods. Online gaming platforms, OTT platforms, online learning providers, social media platforms, enterprise-grade learning management systems, and various other important processes rely on the CDN. Serverless architecture improves CDN performance, particularly for live broadcasting requirements. Resources are allocated depending on the number of users who join, the number of mics connected, the number of visual streams, and the like. A serverless system can automatically optimize delivery environments based on concurrent user volume and real-time data streams.

6 Key Components of Serverless Architecture

1. Function as a service (FaaS)

FaaS is the foundational building block of serverless, responsible for executing the logic that determines how resources are allocated in a given scenario. Depending on the cloud environment in use, you can select a purpose-built FaaS offering like AWS Lambda for Amazon Web Services (AWS), Microsoft Azure Functions for Azure, Google Cloud Functions for the Google Cloud Platform (GCP), and IBM Cloud Functions for private or hybrid environments. These functions will read your backend database when the user triggers an event and extract and deliver a response.

2. The client interface

The client interface plays a major role in serverless functionality. You cannot force-fit serverless architecture into any application you choose. The interface must be able to support short spurts of requests, stateless interactions, and flexible integrations. The interface must also be designed to be compatible with extremely high volume or low volume data transfers.

3. A web server on the cloud

The web server is where a stateless interaction will be initiated after the user initiates it and before the FaaS service terminates it. The web server is distinct from the backend database, where the information delivered to users is stored. For example, suppose you are an online video content provider. In that case, the web server is where user requests, scripts, FaaS response, etc., are hosted before it is terminated as per the ephemeral nature of serverless. On the other hand, the video content will be kept in backend storage, waiting to be fetched as per user requests.

4. A security service

Security is a key element of serverless operations because:

  • The application handles thousands of concurrent requests. Each request has to be authenticated before sending a response.
  • Due to its stateless nature, past interaction history isn’t stored. The application cannot fall back on previous interactions to validate future ones.
  • The serverless model makes transparency and monitoring more difficult. You have to obtain security intelligence from millions of events that are logged every day.
  • The distributed nature of serverless architecture means that there are multiple services and vendors involved. The full landscape has to be secured.

Typically, serverless applications use a token service, where temporary credentials are generated for users and can be used to invoke the function. You can also integrate serverless-ready identity and access management services into your application. For example, AWS Cognito works with AWS Lambda to authenticate user identity through SSO or social networks. You may find similar services for the cloud vendor of your choice.

5. Backend database

The backend database is where the information to be shared with the user is stored. This could range from static content repositories to SQL databases, from media storage to live broadcasting modes. Typically developers use backend as a service (BaaS) solutions to further cut down maintenance and admin efforts. Also, most cloud vendors provide BaaS solutions compatible with their FaaS offering.

6. API gateway

The API gateway connects components 1 and 2 – i.e., FaaS and the client interface. When the user initiates an action, it is relayed across the API gateway to trigger an event via the FaaS service. The gateway can connect the client interface to multiple FaaS services and increase the application’s functional features.

Examples and Use Cases of Serverless

Leading companies around the world have leveraged serverless computing to deliver high-performance, high-availability online services to their customers. Some of the notable examples include:

1. Real-time data updates by Major League Baseball Advanced Media (MLBAM)

Major league baseball is one of the oldest and largest professional sports leagues in the U.S. the company operates a product called Statcast, which provides users with accurate and real-time sports metrics. The Statcast website allows you to run complex queries around data like pitch velocity, pitch type, season type, and specific player names. By using serverless computing, it can deliver accurate statistics and inform user decisions around baseball games.

2. Rapid application development and deployment by Autodesk

Autodesk delivers powerful software for construction, architecture, and engineering industries, which are both bandwidth-intensive and mission-critical for its users. It came out with a new product called Tailor, which would quickly create custom Autodesk accounts for companies with all the necessary configurations. By using a serverless architecture, Autodesk was able to launch Tailor in just two weeks, with only two FTES responsible for the solution.

3. Scalable on-demand media delivery by Netflix

One of the world’s largest over the top (OTT) media providers, Netflix is a long-time proponent of serverless computing. It has been using serverless since 2017 and before, building a platform that can handle thousands of changes every day. Developers at Netflix are only tasked with defining the adapter code, which dictates the platform’s response to user requests and computing conditions. The actual platform adjustments, provisioning, and end-user delivery is handled by serverless architecture – at the heart of Netflix’s proprietary Dynamic Scripting Platform.

4. Dynamic and responsive chatbots by Slack

Serverless is well-suited to single-function applications like chatbots. Bots may face myriad requests every day of varying complexity. Assigning a static server to chatbots could lead to underutilized bandwidth or capacity crunch due to the unpredictable nature of chatbot user needs. That’s why Slack uses a serverless, cloud-based architecture centered on AWS Lambda.

5. IoT-based smart vending machines by Coca-Cola

Coca-Cola switched to serverless and cloud-based vending machines in 2016 and saved thousands of dollars per year. The company’s smart vending machine called Freestyle allows customers to order a beverage, pay online, receive the beverage, and obtain a confirmation message on their mobile phone. Before switching to serverless, Coca-Cola was spending around $13000 per year per machine – this came down to $4,500 after serverless implementation. Further, during the pandemic, Freestyle machines handled approximately 80 million requests per month (much more than the 30 million expected) through a fully touchless experience.

6. IoT garbage collection by GreenQ

GreenQ is a smart waste management solution provider. It uses serverless technology built on IBM OpenWhisk to connect with sensors across garbage trucks, traffic monitoring systems, and residential waste pattern analytics systems. Serverless architecture allows GreenQ to fetch dynamically updated data and optimize garbage collection routes in real-time.

7. Data-driven clinical decision-making by IDEXX

IDEXX is a U.S.-based multinational that develops animal husbandry, water, dairy-related products. It’s traded on the NASDAQ and is among the global leaders in this space. The company used serverless tools from Google to launch its new product, VetConnect PLUS. VetCONNECT PLUS fetches information from over 1 billion test results across 30,000 veterinary practices worldwide, along with IDEXX Reference Laboratories, to deliver diagnostic summaries. The serverless architecture allows VetCONNECT PLUS to accommodate 30 terabytes of data and save up to $500,000 in annual IT costs.

1 thought on “Serverless – API Architecture Style Every Developer Must Know”

  1. Pingback: Modern Cloud infrastructure TECH SHITANSHU popular boom 1

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top