serverless database
What is a serverless database?
A serverless database is a type of cloud database that is fully managed for an organization by a cloud service provider and runs on demand as needed to support applications. The database system automatically scales up or down when workloads change, and bills are based on the amount of data processing and storage resources that a customer uses.
The term serverless implies that the database runs without the use of servers, but that isn't technically accurate. Serverless databases rely on servers, storage devices and other IT infrastructure that cloud providers deploy in their data centers. However, a user organization doesn't need to set up and manage its own servers or compute instances in the cloud. As a result, the databases are effectively serverless from its standpoint.
Serverless databases are one aspect of serverless computing, a broader concept that was initially popularized by Amazon Web Services with its AWS Lambda compute service. AWS introduced Lambda in 2014, and other cloud providers launched similar offerings. In its original form, serverless computing focused on enabling function as a service (FaaS) capabilities, in which microservices run only when needed for a brief period of time as part of an application workflow.
A serverless database isn't quite the same as FaaS because it requires a persistent data layer that is provided as part of the managed service. However, the database's query engine runs only as needed, and there are no defined limits on processing capacity, concurrent user connections or number of queries.
How do serverless databases work?
Serverless databases operate in a cloud model that abstracts IT infrastructure provisioning and server management away from the user. Typically, a serverless database doesn't have dedicated servers and the compute resources that support it aren't always running. Instead, they're started -- or spun up, in IT parlance -- when required by applications.
The process of how serverless database operations work includes the following steps:
- A client application makes a request to the database, and the cloud provider routes the request to the serverless database service.
- The serverless database automatically spins up the compute resources needed to handle the request. This might be a single compute instance for a simple request or multiple instances for a complex query. Some serverless database providers might offer the option of a warm start where there is a pool of always-on compute instances that are ready to respond to user requests in a multi-tenant environment.
- With the compute instance up and running, the server makes data query requests to get whatever data is needed from the storage layer. That is typically a managed cloud storage service, such as Amazon S3 or Microsoft's Azure Blob Storage.
- Once the request is completed, the compute resources are shut down automatically, while the storage layer remains persistent.
- When the next request comes in, this process repeats with new compute resources spun up to handle it. The database scales up and down automatically based on workload demands.
- The user organization is billed only for the actual compute resources used to process each request.
Serverless database vs. database as a service (DBaaS)
In the cloud, serverless database offerings were predated by database as a service (DBaaS) ones. Both are managed services, and database vendors sometimes use the two terms interchangeably. There are some differences between the technologies, though. With DBaaS, for example, deployments and pricing are often based on a set amount of system resources -- sometimes referred to as a T-shirt sizing method, with small, medium and large offerings.
The table below provides more details on the distinctions between the two types of cloud database services.
DBaaS | Serverless database | |
Deployment model | Requires users to choose a specific instance size or configuration, which involves estimating resource needs in advance. | Automatically provides required compute and storage resources based on application demands, eliminating the need for upfront resource planning. |
Resource management | Users must manage resource allocation and scaling although the cloud provider might offer tools to assist in the process. | Eliminates the need for resource management by automatically scaling system resources up or down based on workloads. |
Pricing model | Often has a fixed pricing model based on the provisioned resources. On-demand pricing is also available, but users must self-manage resources. | Operates on a consumption-based pricing model, charging users based on the resources used during database operations. |
IT infrastructure | Users have dedicated computing resources for their databases, ensuring consistent and predictable performance. | Operates in a shared infrastructure to optimize costs, which might lead to performance fluctuations depending on the activities of other users. |
Database administration and management | Requires involvement in tasks such as backups, patching, scaling and cost management, although some hands-on work is done by the provider. | Significantly reduces management overhead by automatically handling backups, patches, scaling and other database administration tasks. |
Potential benefits of using serverless databases
Serverless databases offer user organizations the following potential benefits over conventional self-managed databases and DBaaS deployments:
- Cost efficiency. The pay-as-you-go approach provides opportunities for more cost-efficient database operations. As opposed to running an on-premises database, there's no need to pay for server infrastructure and ongoing hardware and software maintenance. Consumption-based pricing under the serverless model can also cost less than DBaaS environments and self-managed databases in the cloud although organizations should closely monitor expenses to avoid unexpected cost overruns.
- Simplified IT operations. The serverless database model is ideal for organizations that just want their developers to build cloud applications that can be deployed and run without needing to worry about ongoing database management.
- Auto-scaling of database resources. The core design of serverless databases enables automatic resource scaling without database administrators or developers first having to figure out how much database capacity is required as processing workloads and data needs change.
- High availability and fault tolerance. A serverless database's underlying architecture is typically distributed and redundant, which helps to enable highly available and fault-tolerant systems that lower the risk of service outages or failures.
- Better user experience for developers. Many serverless database services are focused on improving the developer experience by providing APIs and easy interface access to enable rapid application development and deployment.
Serverless database types and examples
As is the case with databases in general, there are different types of serverless databases that provide distinct features and capabilities and cater to different application requirements. For users, the choice between them depends on specific project needs, such as the type of data model being used, scalability requirements and the complexity of the planned data processing operations.
Here are common serverless database categories, along with some examples of database management systems that are offered in each one.
Serverless relational databases
These databases use Structured Query Language (SQL) and the relational model, which organizes data in tables and uses a fixed schema to support data consistency, integrity and reliability. The most widely used database technology overall, relational databases are ideal for processing complex transactions and queries involving structured data.
Examples of serverless relational databases include the following:
- Amazon Aurora Serverless (AWS).
- Azure SQL Database serverless (Microsoft).
- Cloud SQL (Google).
- CockroachDB Serverless.
- Oracle Autonomous Database Serverless.
- PlanetScale.
Serverless NoSQL databases
NoSQL databases offer flexible schema designs and are suitable for handling large volumes of structured, unstructured and semistructured data in applications that require scalable processing. NoSQL itself includes a combination of different database technologies -- most notably, key-value stores, document databases, wide column stores and graph databases. Many NoSQL products now support multiple models across those categories plus some level of SQL capabilities.
The following are examples of serverless NoSQL databases:
- Amazon DynamoDB (AWS).
- Amazon Neptune serverless (AWS).
- Azure Cosmos DB serverless (Microsoft).
- DataStax Astra DB.
- Fauna.
- Firestore (Google).
- MongoDB Atlas.
Specialized serverless databases
Special-purpose databases that are available in serverless versions include time series databases, which are designed to handle time-stamped data collected sequentially, and vector databases that are used for large-scale similarity searches on unstructured data in AI, machine learning and image retrieval applications. Examples of time series serverless databases include InfluxDB Cloud Serverless and Amazon Timestream for both InfluxDB and LiveAnalytics, while Pinecone and Amazon OpenSearch Serverless offer serverless vector database engines.
Key considerations for deciding whether to use a serverless database
There are various factors to consider when deciding whether to use a serverless database or a different option, including the following:
- On-premises or cloud deployment. One of the first and most fundamental considerations is whether an organization should run an on-premises or cloud database.
- Application workload patterns. Serverless databases tend to work best for workloads with variable or unpredictable traffic, because they can automatically scale to meet data processing demands.
- Operational costs. Serverless databases can be cost-effective for applications with sporadic traffic but might become expensive for constant high-volume workloads due to the pay-as-you-go pricing model.
- Developer efficiency. Evaluate the possibility of reduced operational overhead for developers. Serverless databases generally enable them to focus more on application development and less on database management issues.
- Performance requirements. Assess the performance characteristics of serverless database technologies, including potential latency issues and the ability to meet application performance benchmarks when workloads are scaling up.
- Ensure data security and compliance. While providers generally offer robust security features, responsibility for securing application data and managing access controls still ultimately lies with the user.
As part of the evaluation process, organizations should also consider the possible disadvantages of using serverless databases, including the following:
- Cold-start performance latency. In some serverless database deployments, users can experience latency as the serverless functions initially start up. It's a phenomenon known as cold starts that could affect performance-sensitive applications.
- Limited configuration control. The serverless model offers less control over a database's underlying infrastructure and configuration settings compared to a traditional database deployment.
- Unpredictable costs. Accurately predicting the cost of a serverless database environment can be difficult due to consumption-based pricing, especially with highly variable workloads.