Azure Serverless Architecture
In this article, we'll look at what serverless is, explore some of the use cases, and consider common patterns and antipatterns that are likely to trip up.
Join the DZone community and get the full member experience.
Join For FreeCloud computing allows you to experience the benefits of serverless architecture without worrying about the underlying infrastructure. In this article, we'll look at what serverless is and why it's a good fit for your business. We'll also explore some of the best use cases for serverless, including how to implement it in your organization and how you can scale up when you need to increase resources. Finally, we'll consider common patterns and antipatterns that are likely to trip up any organization that adopts this approach.
What Are Azure Serverless/Functions?
Azure Functions is a cloud service available on demand that provides all the infrastructure and resources needed to run your applications. It's a small piece of code that runs in the cloud using Azure Functions Service. Functions provide serverless computing for Azure, which means that there is no need for you to manage servers or Compute resources. This will help developers to maintain less infrastructure and save on costs.
Why We Need This?
Serverless functions improve your application's performance and the experience of your developers and customers.
Benefits
- These are easier to write and deploy on an Azure environment.
- No need to worry about Server infra, runtime, etc.
- It is highly scalable. When demand increases automatically, the required resources will be allocated, and when the demand falls, the extra resources get dropped off automatically.
- These are very lightweight and serverless.
- It is event-based, i.e., trigger function based on an event.
- It is supported by different Azure security services like Azure active directory etc.
- These are fast to execute because there is no large application, start-up time, initialization, and other events fired before the code is executed.
- These support variety of programming languages, including C#, F#, Java, JavaScript, TypeScript, and Python.
- These can be built, tested, and deployed in the Azure portal using a browser.
- Using Visual Studio, developers can test these locally using the Azure Storage emulator.
Serverless Functions Architecture
A serverless architecture separates the code from its hosting environment, allowing you to define triggers that invoke functions, which can be manual or automated. The result of an execution is the execution of code. In addition, most serverless platforms provide access to pre-defined APIs and bindings to streamline tasks such as writing to a database or queueing results.
Azure Compute Level Comparision
Iaas
PaaS
Container
Serverless
Scale
VM
Instance
App
Function
Abstracts
Hardware
Platform
OS Host
Runtime
Unit
VM
Project
Image
Code
Lifetime
Months
Days to Months
Minutes to Days
Milliseconds to Minutes
Responsibility
Application dependencies,
runtime and OS
Application dependencies
Application dependencies,
runtime a
Functions
|
Iaas |
PaaS |
Container |
Serverless |
Scale |
VM |
Instance |
App |
Function |
Abstracts |
Hardware |
Platform |
OS Host |
Runtime |
Unit |
VM |
Project |
Image |
Code |
Lifetime |
Months |
Days to Months |
Minutes to Days |
Milliseconds to Minutes |
Responsibility |
Application dependencies, |
Application dependencies |
Application dependencies, |
Functions |
Architecture
The WebJobs Core provides an execution context for the function and a platform for executing the function. The Language Runtime is responsible for running scripts, executing libraries, and hosting the framework for the target language. For example, Node.js is used to run JavaScript functions, and the .NET Framework is used to run C# functions.
Serverless Architecture Patterns
1. For Web Applications and Mobile
A web application backend for a retail scenario is used to pick up online orders from a queue and process them. The resulting data is stored in a database.
Example:
The data can be mapped to Cosmos DB or saved to Blob Storage, depending on whether the data is structured or unstructured.
2. Real-Time and Batch Processing of Files
Real-time file processing, like generating instant invoices and calculating revenues continuously. The files can be processed by using OCR detection and adds it to a database for easy queries. (OR) Analyzing duplicate data based on frequency defined on submitted applications for any course in an educational institution.
Example:
Batch processing and near real-time data processing.
3. Real-Time Stream Processing Independent Software Vendor (ISV) Scenario
A near real-time data, like data generated from "Air Quality Sensors," to determine air quality categories.
Example:
Anti-patterns
The Serverless architecture is not suitable for all use cases, but there are some circumstances in which it may not be appropriate.
- Shared Code/Logic
- Distributed Monoliths
- Complex Processing
- Serverless Big Data ETL Pipeline
- Long Processing Tasks
- Async calls
Conclusion
Microsoft Azure provides a variety of serverless services that help customers build applications quickly. Azure Functions plays a key role in building, testing, and deploying applications with low latency. Azure comes with high scalability and availability. Hosting Single Page Applications directly on Azure Blob Storage without involving any web servers is easy. Major benefits for cost control (PAAS), when compared to servers hosted physically at data, canter to deliver services. Azure Functions, SQL, and Logic Apps are the most common and highly utilized serverless services to design fault-tolerant applications.
Opinions expressed by DZone contributors are their own.
Comments