What is the Serverless architecture?






Technology is rapidly growing day by day. New technologies are being introduced to simplify dev works and make applications more efficient. I think you may have heard about Serverless Architecture. In this article, I am going to describe more about Serverless. Let’s begin the story. Here I am going to explain the below points.

  • Why Serverless
  • Serverless functions
  • Databases for serverless
  • Advantages and disadvantages of Serverless


Can we deploy web applications without Servers?





No, we need to have physical servers somewhere else to deploy our applications. There are web servers, file servers, mail servers…etc. Nowadays we are dealing with the cloud, all cloud providers already provide those specific services on the cloud.


Monolith to serverless


Years ago we were very satisfied with Monolithic Architecture. A bulky single application contains everything. Then we came across Microservices architecture to avoid the drawbacks of the Monolithic. Microservices use separate services that are dedicated to a specific task to perform. Now we are on another level with serverless. It simplifies services even smaller with functions. The important thing is, that these functions will be managed by a cloud provider, you do not need to care about it.

What is called Serverless?

  • Simply said, “as a developer, you don’t need to bother about the servers” is what Serverless means.
  • On your behalf, your cloud provider will handle this.
  • At least you don’t need to think about it. It is not necessary to create servers, maintain servers, deploy servers…etc.
  • You can fully focus on the development without worrying about the deployment.


Okay, no servers. Then, as developers what should we care about?

The answer is “Serverless functions”


How to select a database for serverless architecture?


This is another important factor. If we are working with Serverless, we need to have Serverless databases. There are two types of databases.






What are Serverless functions?

  • Serverless functions are single-purpose programmatic functions.
  • It is just a simple function.
  • The developer can focus on the logic and create a function and your cloud provider will deploy it, scale it, maintain it, and takes care of it.
  • You can write your serverless functions in different languages which is supported by your cloud provider.

Serverless infrastructure providers


Most of the common cloud providers provide serverless functions enabling serverless services and functionalities.
  • AWS Lambda functions
  • Google Cloud functions
  • Azure functions
  • Cloudflare Workers
  • Digital Ocean functions
  • Alibaba Cloud functions
  • Relational serverless databases
  • NoSQL serverless databases

I assume you all know about the difference between relational databases and NoSQL databases. So I am not going to explain this.


Relational Serverless databases


Since we are dealing with Serverless architecture I encourage you to use NoSQL Serverless databases. But sometimes it might be required to use relational databases with your requirements.

Amazon Aurora

If you are using AWS, you can use Amazon Aurora RDBMS. This is fully compatible with MySQL and PostgreSQL. According to the official page of Amazon Aurora, they offer the features mentioned below.
  • Provides very powerful and high-performance data handling.
  • In build security
  • Continuous backup
  • Up to 15 read replicas
  • Automated multi-Region replication

CockroachDB


This is another cloud-based database that is compatible with PostgreSQL. Here are some features they offered as they mentioned on their official page.
  • Start instantly
  • Auto replicated data
  • Online schema changes

PlanetScaleDB


If you are looking for a MySQL-compatible relational serverless database, PlanetScaleDB would be a choice.
  • High scalability with horizontal sharding.
  • Unlimited connections
  • Effortless data import


NoSQL serverless databases


NoSQL serverless databases are very popular because they can handle a large amount of data in many forms.

Amazon DynamoDB

  • The NoSQL database for AWS is Amazon DynamoDB.
  • Fully managed NoSQL document and key value database with auto-scaling.
  • Highly scalable with customizable capacity modes.
  • This offers single-digit millisecond performance at any scale.
  • Guaranteed high security with AWS IAM and AWS KMS.

Google Firestore

  • Firestore is GCP’s database solution for Serverless.
  • This is a real-time database.
  • This is a highly scalable NoSQL document database.
  • Data is fully secured with customizable security and data validation rules.
  • Offline mode enabled easy development.

Azure Cosmos DB

  • This is a Microsoft product for the Azure cloud.
  • CosmosDB also has common serverless database features like scalability, security, and performance.
  • Supports different APIs like MongoDB API, Gremlin API, Tables API and DocumentDB API.


Advantages of Serverless


Avoid over-provisioning and under-provisioning.


Over-provisioning means you are paying for some sort of server capacity, but you are not using this capacity. It looks like you are expecting traffic for 1M users, but you are getting 1K users.

Under-provisioning means your expected capacity is less than the required capacity. In simple words, you are expecting traffic for 1K users, but you are getting 1M. The server doesn’t have enough capacity.

Pay for the exact usage


Serverless functions allow you to pay only for the usage you consume. Please take a look at the pricing section of your cloud service provider.

Smart scalability


Serverless models will automatically scale on demand. The cloud provider is smart enough to identify the required capacity and it will automatically scale high or low on demand.

Free of servers, no infrastructure to manage.


You don’t need to worry about server maintenance, software/hardware upgrades, security updates, or anything related to servers.

Highly available


Cloud providers guaranteed availability because their data centers are highly available and secure in different regions all around the world.

Boundless


Serverless functions can be written in many languages. So developers who are skilled in different languages can work to gather.


Disadvantages of Serverless


Latency


It will take a little bit of time to wake up and return the response. Because some serverless functions will run on demand.

Cost

It depends on your traffic. If you are getting more traffic, your cost will be high. But compared to serverful, it will reduce server maintenance costs, resource costs, and other specific server-related costs.

Debugging

This is one of the major factors and the most contestable. If you are using AWS Lambda, you can use the AWS toolkit and debuggers. If you are using GCP, you can use the Functions framework. Anyway, this might not be easy. Because your functions are there, authentication is somewhere else, and you may have an API gateway too. It will not be easy to replicate the complete production environment locally.



I hope you can have a rough idea about Serverless if you are just a beginner. You can refer to the docs of the cloud providers like AWS, GCP, Azure… etc to get a complete idea about Serverless. You can find the same article on Medium
What is the Serverless architecture? What is the Serverless architecture? Reviewed by Ravi Yasas on 12:13 PM Rating: 5

No comments:

Powered by Blogger.