Software developers are always worrying about infrastructure issues and server maintenance, but now they can forget about all this administrative overhead. With serverless computing, their dreams about focusing entirely on writing code can finally come true.
In this article, we explain the principles of serverless computing, underscore the pros and cons of this technology, and provide an overview of its short-term prospects.
This article will be useful for developers who are considering using serverless technology as well as for organizations that are looking for easy and fast software development.
The term serverless computing is a misnomer as the technology uses servers, only they’re maintained by the provider. Serverless computing is considered a new generation of Platform as a Service, as in this case, the cloud service provider takes care of receiving client requests and responding to them, monitoring operations, scheduling tasks, and planning capacity. Thus, developers have no need to think about server and infrastructure issues and can entirely concentrate on writing software code.
Serverless computing is also sometimes called Function as a Service or event-based programming, as it uses functions as the deployment unit. The event-driven approach means that no resources are used when no functions are executed or an application doesn’t run. It also means that developers don’t have to pay for idle time. In addition, a serverless architecture ensures auto-scaling, allowing applications to provide users with services in spite of increasing workload.
Thanks to all these features, serverless computing is considered a cost-saving, resource-limited, and fault-tolerant approach to software development. This novel approach is already provided by such industry giants as Amazon, Google, IBM, and Microsoft.
Serverless architecture run applications that depend on external Function as a Service and Backend as a Service providers, which run the application code in temporary containers.
Consequently, a serverless architecture includes the following three core components:
- API gateway — This is a fully managed service that’s used to define, deploy, and maintain APIs. For API integrations, developers use standard HTTPS requests that connect their presentation tier with the functions they write on a serverless platform. Some serverless providers like Amazon offer their own API gateways for their clients.
- Function as a Service (FaaS) — This is the layer that executes the application code (business logic) through multi-protocol triggers. Function instances are provisioned on request (in a few milliseconds) in сompliance with associated configurations.
- Backend as a Service (BaaS) — This is a cloud computing service model that serves as a cloud-based distributed database, eliminating the need for administrative overhead. BaaS features include cloud storage, push notifications, server code, user and file management, and many other backend services. These services have their own APIs so developers can easily integrate them into their applications.
To create an application, developers should consider how to break it into smaller functions to reach a granular level for serverless compatibility. Each function needs to be written in one of the programming languages supported by the serverless provider.
Deploying a function is considerably different from deploying a traditional system as there’s no server on the developer’s side. In serverless computing, a developer just uploads function code to the serverless platform and the provider is responsible for its execution as well as for provisioning and allocating resources, maintaining the virtual machine, and managing processes. The platform vendor also takes care of automatic horizontal and elastic scaling.
FaaS functions are executable on a container with few resources. Functions are triggered through requests and events when necessary without requiring the application to be running all the time. Requests that can trigger FaaS functions are specified by the provider. For instance, such triggers can be inbound HTTP requests, scheduled tasks, S3 updates, or messages added to a message bus. Functions can also be invoked via a platform-provided API, externally, or within the cloud environment.
Functions in serverless computing have significant architectural restrictions related to their state and duration of execution. FaaS functions are stateless, which means that they have no machine state. Thus, external databases are necessary to simulate state behavior of functions.
Moreover, functions are limited in their execution time, which determines how long each invocation can be run. This restriction makes developers create several short-running functions instead of one long-running task.
In order to initialize an instance of a function in response to an event, a FaaS platform requires some time for a cold start. This leads to startup latency that depends on various factors and has an unpredictable duration. It may be caused by the programming language, the number of libraries you use, the configuration of the function environment, and so on. Though latency raises many concerns, the latency your app experiences will depend on the traffic and type of your application. If a function repeats frequently, a cold start will be rare, as the platform reuses the instance of a function and its host container from a previous event.
The term serverless became popular in 2014 after Amazon launched AWS Lambda, a serverless platform that was followed by the Amazon API Gateway in 2015. By the middle of 2016, the serverless concept had given birth to the Serverless Conference, after which other vendors began to introduce their own solutions to the market. Currently, all tech giants provide a serverless architecture.
- Amazon’s Lambda is the most mature serverless platform on the market. It supports a variety of programming languages including Java, Python, and Node.js. Lambda takes advantage of most AWS services and allows developers to apply its functions as event handlers as well as to provide glue code when composing services.
- IBM Cloud Functions is another serverless deployment that acts as an event action platform for creating composite functions. It supports Node.js, Java, Swift, Python, and arbitrary binaries embedded in a Docker container. Cloud Function is based on OpenWhisk, which is available on GitHub under an Apache open source license.
- Microsoft Azure Functions lets developers write code for functions like processing images, sending emails, and maintaining files that are executed on schedule or when needed. The platform provides HTTP webhooks, integration with Azure, and support for such programming languages as .NET, Go, Node.js, Python, PHP, and Java. The runtime code is open-source and is available on GitHub under an MIT License.
- Google Cloud Functions is a computing platform that provides basic FaaS functionality to run serverless functions written in Node.js in response to HTTP calls and events from Google Cloud services. It provides development tools such as prediction APIs, translation APIs, and data storage.
Serverless computing is more beneficial than existing cloud services as it offers better application performance along with reduced operational costs. Let’s consider other benefits of cloud computing that attract so much attention to this technology.
- Reduced cloud costs — Serverless computing is based on the principle of pay-as-you-go. It costs nothing when your application doesn’t run. Developers pay only for the time when their application executes a user’s functions in response to specific events or requests. This model greatly benefits developers, as they can significantly save cloud costs.
- Reduced development costs — With serverless computing, there’s no need to handle updates or infrastructure maintenance as developers can now rent most of the resources necessary for software development.
- Improved resource management — Applications developed in serverless environments are more fine-grained. This means that the cloud provider can closely match abstract demand to actual system resources. When an application doesn’t run, the cloud provider distributes the server resources among other running applications. Once a triggering event appears, resources are allocated to execute the function.
- Elastic scalability — A serverless architecture has the ability to scale up and down according to application workload. This is achieved by replicating functions. Developers no longer need to purchase additional infrastructure for handling unexpected growth.
- Fewer responsibilities for developers — In the serverless model, the cloud provider has more control over resources and more insight into the context of application behavior. Developers don’t need to care about workload intensity, resource distribution, scaling, and application deployment as these issues are in the hands of the cloud provider.
- Faster releases and reduced time to market — To deploy new functions, developers just need to compile their code, zip it, and upload it to the serverless platform. There’s no need to write any scripts to deploy functions. This leads to faster releases and time-to-market reductions of up to two-thirds according to a study by Microsoft.
- Agile-friendly development — Serverless computing allows developers to concentrate on application code rather than infrastructure maintenance. Moreover, it benefits developers through reduced software complexity and better code optimization. For instance, if an application usually takes one second to execute an operation with a hardware server, in a serverless environment it may take only 200 milliseconds, so developers can save 80 percent of their costs.
- Multi-language support — Currently, some serverless platforms support multiple programming languages, so developers can choose the most convenient for them.
- Built-in logging and monitoring mechanisms — Serverless providers have developed their own solutions for user logging and monitoring that eliminate the need for developers to purchase third-party tools for similar purposes. In addition, serverless providers offer function-level auditing that ensures the application data privacy that’s necessary for full GDPR compliance.
Despite the many benefits, you should understand that serverless computing is a relatively new technology that also has certain challenges.
- Costs of serverless services — While serverless computing can significantly reduce your development costs, this isn’t always true with different cloud computation approaches. For instance, serverless functions are currently most attractive for CPU-bound computations, while I/O bound functions are not as affordable as on dedicated virtual machines or containers.
- Cold start — The key benefit of serverless computing is its ability to scale to zero so that developers don’t need pay for idle time. However, this may lead to increased invocation latency due to cold starts. For instance, it may occasionally take up to ten full seconds to run the first invocation of a JVM-implemented function. Preemptive warming up could be a good solution to this problem, but developers may have to pay penalties for getting their serverless code ready to run. Another solution could be using tools that can predict system load and analyze the duration of load spikes.
- Resource limits — Resource limits are necessary to ensure that the platform can deal with spikes and withstand attacks. Serverless computing imposes limits on memory, function execution time, bandwidth, and CPU usage. For instance, the maximum execution time per request is 300 seconds (or 5 minutes) for Azure Functions and AWS Lambda.
- Inadequate application testing — Though it’s easy to test different functions of an application, it may be challenging to test the infrastructure and the combination of all functions. The reason for this is the complexity of the serverless architecture, which makes it difficult to manage the countless endpoints in different environments.
- Increased security concerns — There are high security risks in a serverless environment, as many users run their functions on a shared platform. Thus, if someone loads malicious code, it may negatively affect all cloud users.
- Vendor compatibility — FaaS providers operate on different platforms and support different programming languages. Thus, software changes may be inevitable if developers want to change providers.
- Monitoring and debugging — Since developers have no control over the provider’s servers, there are limited opportunities for identifying problems and bottlenecks. After a function is executed, it only leaves traces in logs recorded by the serverless platform. In addition, there’s a lack of debugging tools that can operate in serverless environments. This is because debugging distributed systems requires access to a substantial number of relevant metrics in order to identify the root causes of problems.
- Function state — While real applications require state, it’s not clear how to manage state in serverless functions, as they’re stateless. In order to overcome this challenge, programming models, libraries, and tools need to provide the necessary levels of abstraction.
- Execution time limitations — Serverless functions are limited in their execution time, but not all applications can run only with short-running functions. There are cases when long-running logic is necessary, for instance for financial or emergency applications.
- Availability of skills — Serverless computing is a fairly new business, so there’s a lack of developers on the market with skills in serverless programming. Software companies may have to invest in training their developers in order to catch up with new business trends.
- Composability — Some functions are designed to call other functions and coordinate the execution of several functions that may result in parallel execution. To overcome this challenge, it’s necessary to use tools that can facilitate the creation and maintenance of compositions.
- Multi-tenancy concerns — In addition to your application, a serverless provider also supports other clients. Thus, there’s a risk that your software will be placed on the server along with function-heavy applications that may cause slow performance.
- Access to the file system level — A serverless architecture isn’t the best choice for software that requires access to the file system or operating system level. These types of applications need to do things such as read attributes from configuration files or split in-memory cache to disk, but serverless functions don’t allow for this.
Serverless computing is a young technology, so its future is yet to be determined. If serverless providers manage to overcome the challenges of FaaS services, the technology will be able to radically change software development in the coming years.
Gartner predicts that serverless computing will reach the peak of its productivity in two to four years and that it will be implemented in areas beyond IT. In addition, Tim Wagner, General Manager of AWS Lambda, reported at ServerlessConf 2017 that serverless adoption is moving ten times faster than the adoption of containers. He also pointed out that there’s an impressive trend of FaaS adoption in enterprises.
IT industry experts also predict that we’ll see the first uses of serverless software by the end of 2018. Serverless computing can be used for developing image-rich applications, virtual assistants, chatbots, web apps, and websites. In addition, the technology can be applied to mobile backends, media and log processing, IT automation, and real-time streaming data processing.
In addition, there are expectations that serverless computing will stimulate the development of applications for advanced technologies. Particularly, this technology can help simplify the complexity of big data thanks to its elastic auto-scaling. It’s best suited for software that doesn’t run continuously but rather has quiet periods and peaks of traffic. So serverless platforms can be used for developing applications that easily integrate with various advanced technologies like Internet of Things devices, cognitive intelligence, data analytics, and mobile devices.
Serverless computing is a novel and promising approach to software development. The technology eliminates the complexity of dealing with servers and reduces development costs. It lets developers concentrate on development and stop worrying about budget limitations thanks to pay-per-use billing. Though serverless computing is a new technology full of challenges, the Apriorit team has already used it in our projects. If you’re looking for cost-effective yet high-quality and time-efficient software development, we can offer you our services.