Today cloud services, including Software as a Service (SaaS), Platform as a Service (PaaS), and Infrastructure as a Service (IaaS) are widely used as they provide on-demand delivery of services and resources for all types of software. They are scalable, flexible and cost-effective. Cloud computing is evolving swiftly and serverless architecture is its new execution model. While in traditional applications, server is always considered, in serverless architecture it is the code. This is also described as Function as a Service (FaaS).
What is Serverless Architecture?
It is actually not “server-less” literally, but instead of running a single large application in a cloud or a dedicated server, it is split into multiple independent isolated event driven micro-services or functions. Developers can write each module or micro-services in a different language and can host them in different clouds.
A well-planned serverless architecture can make the maintenance or future updates of the software easier.
Difference between Serverless and Traditional Architecture
In traditional architecture, the application is divided into several modules in different layers. Each module has specific business functions. It can also interact with other external services. All calls to external services are through the application, making it act as the entry and exit point for all interactions.
In serverless architecture, the application is split into several small functions called micro-services. Depending on the load the application is scaled automatically. The client application consumes different micro-services or functions that are hosted on diverse platforms, languages, locations. The functions are loaded only when they are required or being requested, thus making booting light-weight and quick. Each function is executed by a trigger that can be an event or the culmination of another trigger. These functions can be services hosted in a cloud or functions provided by third party providers, using the user register process. Serverless architecture, in fact, largely depends on third party service providers.
Let us suppose a user is filling a form and uploading an image. Actions like uploading image to cloud storage and saving information to database are handled by the server application.
Depending on the client device, the size of the image might vary. For example, an image uploaded from a mobile device might be larger in size compared to an image uploaded from a PC. These images must hence be optimized before saving as a file. In serverless architecture, the process is split into multiple functions. When a user submits the form, the server will trigger an event function which will upload the image to the cloud storage. This is followed by another event to save data to the database. Finally, the function to send a confirmation Email is triggered.
Pros and Cons
- Reduced time to hit online: Developers can develop functions, without waiting for the completion of the entire software, and host them on the cloud with ease. This enables faster debugging and delivery of changes.
- Reduced cost: When functions and micro-services are availed from third-party service providers, the set up and maintenance cost of the services rely completely on the service providers. This means you have to pay only for the runtime of the functions and not for under-utilized resources.
- Scalability: Micro-services have the ability to auto scale depending on the load on the server.
- Modularity: Application is split up into functions that can be developed in different languages and hosted in different servers.
- Increase in complexity: Micro-services increase the number of code files spread in different servers. As the size of the application increases, the complexity also increases.
- Service agreements: It is not appropriate for applications that require special requirements or service level agreements.
- Data security: It is not advised for mission critical systems, as the services would be accessing the public cloud.
- Dependency on 3rd party or cloud provider functions: You get locked to a specific vendor at the infrastructure and code levels.
- Code reliability: If you are using the functions provided by another provider, you are dependent on the code written by another. Thus, you must be sure of how the system will work after periodic feature updates.
To sum it all up, serverless architecture helps developers achieve faster development and deployment of software and eliminates the need for dedicated and high capacity servers. Though serverless architecture comes with many advantages, it is advised to consider all the aspects holistically before taking the plunge.
Few giants offering cloud-based serverless services are Amazon Web Services Lambda, Microsoft Azure Functions, Google Cloud Functions and Docker.