DEV Community

Aavash Shrestha for Deta

Posted on

Choosing the Right Database for Serverless Applications

Serverlesss computing, where compute instances are provisioned and destroyed on the fly, ditches the idea of long running servers. Traditional databases were designed primarily for self-managed long running servers. This has lead to various problems in using traditional databases with serverless applications:

Provisioning, Scaling and Maintenance

The main idea of serverless is to offload provisioning, scaling, capacity planning and maintenance of servers, and focus on application development.

This conflicts directly with how traditional databases are set up. You have to provision a fixed amount of servers (which do not scale down, you might under-use them), configure scaling policies based on predictions, maintain backups, install updates, and ensure robustness and security.

Persistent Connections

Traditional database clients maintain a persistent connection to the database server and all requests are made on this connection. The set up and tear down of this connection are costly processes. As a result, setting up and maintaining persistent connections every time a new compute instance spins up becomes very inefficient for serverless applications.

Number of Connections

Serverless applications may scale up to hundreds or thousands of concurrent compute instances, which means database servers have to maintain as many connections as number of instances.

This is hard on performance, as a traditional database becomes more inefficient as the number of connections increases, while there is also a limit in the number of connections a single database server can keep open.

Global Access

Serverless compute has made it easier to provide low-latency access to your applications all over the world. However, replicating data and maintaining data consistency across multiple regions is a difficult challenge for traditional databases.

The Solution

Serverless applications require a suitable database designed to meet the needs of the serverless model. The right database should:

  • offer a fully-managed solution; no servers to provision and maintain, on demand scaling (up and down), automated backups, easy recovery, and high security
  • offer an API that does not depend on costly persistent connections, while still remaining fast
  • scale efficiently with the number of serverless compute instances
  • offer global data replication and consistency with low-latency

As serverless computing sees more adoption, more developers will need a suitable database for their serverless needs and move on from implementing workarounds with traditional databases.

And Lastly

Our team at Deta is working hard in building a database that overcomes the inadequacies of traditional databases in serverless applications with focus on end-user simplicity with Deta Base. You can get started here. We highly appreciate any sort of feedback.

Top comments (0)