In this post, we are going to look at the overview of Function as a Service, a concept of serverless computing.
One of the key services provided by cloud computing is Function as a Service (FaaS). Cloud computing is an on-demand availability of data storage, servers, databases, networking, and other computer system resources without human intervention. These services are provided to customers through the internet. As the resources are not tightly coupled and communication between different components happens over the network, hence network latencies and network reliability play a key role. Cloud computing provides high availability, elasticity, performance and ease of use. It follows a distributed architecture and helps customers build a highly available and reliable solution that can easily scale up/down and provides higher performance and computing powers.
Function as a service (FaaS) is a true serverless architecture. It is an event-driven serverless compute architecture. It hides the complexity of building and maintaining the underlying infrastructure typically associated with developing and launching an application. It allows customers to develop, test, run and manage their services or individual components without even considering the complexities of the underlying infrastructure. FaaS is primarily used in building event-driven serverless microservices applications. FaaS was initially offered by startup PiCloud. Currently, it is being offered by major cloud providers like Microsoft, Amazon, Google, etc. Microsoft Azure Function is the FaaS provided by Microsoft.
Benefits of FaaS
In the real-world scenario, it’s very difficult for any developer to learn and manage the underlying infrastructure and build applications on top of it. Time to learn and manage underlying infrastructure is time-consuming and hence slows down the development of new applications. FaaS provides helps in having more focus on adding value instead of managing the infrastructure. Some of the key benefits of FaaS are:
Plug-in and build complex microservices applications
It allows users to leverage the existing cloud services and other third-party services to build applications and rapidly move code from concept to production. Creating Proof of Concepts becomes easy as one has not to worry about the underlying infrastructure and its management.
Cloud function provides key benefits of automatic scaling of the underlying infrastructure. Users don’t have to worry about infrastructure. When the workload increases FaaS triggers an automatic scale-up of the infrastructure. Once the workload is reduced the infrastructure would also be reduced.
Serverless architecture is one of the key software architecture design patterns. Developers need not worry about infrastructure i.e. the server software and the hardware. The developer writes the code and leverages the infrastructure of cloud provider services and other third-party services which is primarily called BaaS (Backend as a Service). BaaS is a cloud service that takes care of the cloud infrastructure and primarily focuses on the automation of backend side development.
The event triggers code to run
FaaS allows the application to run on the cloud-based on an event(trigger) like an update in the database, user access to a backend application, etc. The moment the event occurs these applications start running to process these events and produce corresponding output.
Users are charged on the time of execution of the application primarily called function. It is not charged based on the underlying infrastructure. The more the workload runs the more the user has to pay. When the function is idle and not serving any requests then the user is not charged. So, it truly provides the maximum cloud benefit of pay-per-use. Some cloud providers charge at the level of milliseconds of the execution time of applications.
Reliability and unawareness of Infrastructure
Once you deploy your code into the cloud then you don’t have to worry about infrastructure and reliability. It is completely reliable and highly available to serve all the requests as it scales up and down based on the workload. As the workload increases underlying infrastructure also increases. The User just has to worry about writing the code and testing it and the rest is handled by the cloud function.
Increases the speed of development and hence productivity
The developer has to focus only on their code and hence can build applications very fast. They can choose the language and design of their choice and the rest is handled by the cloud function.
Microsoft Azure Functions
One of the key Azure cloud service provided by Microsoft is Microsoft Azure Function. Microsoft Azure Function is one of the key FaaS providers in the cloud industry. It provides complete, end-to-end development experience to developers like building applications and debugging them locally on various Operating Systems like Windows, Linux, and macOS and then deploying and monitoring them on the cloud with Microsoft Azure Functions. Azure Function is an event-driven serverless compute service which allows the developer to write, deploy and manage their code without caring for the underlying infrastructure. Microsoft has provided extensions and templates in the Visual Studio and Visual Studio Code for development on the local machine and then deploying and integrating with the Azure cloud. These development code editors have eased the development of applications that would run on Azure Functions.
Microsoft Azure Functions provides benefits of event-driven serverless architecture to the developer to help them create microservices by leveraging Azure applications and other third-party applications. It allows developers to take action and respond to events by connecting to data sources or messaging. HTTP-based API endpoints can be built on Azure Function to be accessed by other applications and devices. Azure Functions provides users an intuitive, browser-based user interface allowing users to trigger and schedule the implemented code. Azure services like Azure Storage, Azure SQL DB, and Document DB can be leveraged to persist the data processed by Azure Functions. Here is an example of an event occurring in AzureStorage due to updates and AzureFunction reacting to that event.
Some of the key benefits and the working principle of Azure Functions are:
Event-driven serverless compute and scalable solution
Azure Functions abstracts the infrastructure from the application code. Hence users need not worry about the upgrade/patch of OS and management of other infrastructures. It scales up automatically when the workload increases and scales down when the workload decreases. It also provides features of pre-warmed workers to run applications with no delay after being idle when the load increases.
Azure Functions can be configured to get triggered by background jobs running which detects changes on the Azure Blob storage or other storage devices and HTTP events. HTTP events can be triggered by almost all SaaS products and Azure Functions can react to these events.
Developer experience and flexibility of programming languages
Reliable and secured applications
Azure Functions provide high reliability and security to the applications. Some of them are:
- Provide security by leveraging the Azure Key Vault service for access policies and auditing.
- Application Insights can be used for making the code efficient and highly performant by continuously monitoring the application and providing necessary logs and places of bottlenecks in the application.
- Virtual Network of Azure can be leveraged by applications to isolate these applications from other applications running.
- Allowing access to the applications by using Azure Active Directory.
- Use other azure service and other third-party services to enhance the features of the application.
Flexible hosting plans to provide pay-per-use benefit
Azure Functions provide multiple hosting plans such as consumption plan, premium plan and Azure app service plan for hosting applications on Azure Functions. The developer is charged based on the compute resources used by the application while running on the Azure Function.