Serverless(AWS Lambda/Azure Functions) or Container ?

 

 

In this article we are going to discuss the serverless and container cloud models and in what scenarios we can make the best use of them.
 

What is serverless ?

 

Serverless is a feature provided by cloud computing platforms which allows developers to build applications without installing or managing the servers for deploying their applications. This basically means that a developer can focus just on the code and the server management will be taken care of by teh cloud platform. This feature allows developers to write independent reusable software services without bothering about the infrastructure required to host these services.Serverless does not require any environment maintainence as it is managed by the cloud provider.


Serverless provides support for multiple programming languages like Java, C#, Python and Powershell. The serverless components allow you to add endpoints and host them as REST API's which makes them very useful for loosely coupled and reusable services.
Serverless components also have a timeout feature, which allows them to run only for a set amount of time.

 

What is a container ?

 

A container is a software package along with the required components like libraries, configuration etc. A container can be deployed on premise or in the cloud. A container can have programs running in different programming languages. For examples, a java program and a python program can be a part of a single container. 


A container is used for more complex softwares where a group of software components need to be packaged and run together.For example, a web application using third party software can be packaged into a container along with the third party software.Containers require maintenance to be carried out since the environment for a container is setup by the developer and not the cloud provider.

 

So the question arises when to go for serverless and when to go for container?

 

Serverless components are best suitable for code which serves a specific purpose and does not run for a long time.For example a serverless program could be used to send an email or perform a database transaction. A serverless component can be simply be code written in Java,C#,Python or Powershell. Mutliple serverless components can be a part of an application. One important point to note is that serverless components have a timeout. So, it's not straightforward to implement a long running program as serverless.

Containers are best used for applications which have multiple components and require more control over the environment. For example, a .NET core or J2EE web application can be run using a container. Containers can run for long duration. 

We can also combine containers and serverless. In this scenario, the front end application which is always running will be a container. The various functionalities performed by the application like create, read, update and delete can be done through serverles API's.

 

Both serverless and containers are useful features of cloud platforms which can be used create portable and scalable applications.