For Data Engineers

Getting Started With FeatureBase Serverless

The serverless version of FeatureBase has come to FeatureBase Cloud and is available to try NOW! Here’s a brief walkthrough of how you can experience the same low-latency, high throughput database you know and love in a serverless fashion.

Shameless Plug by the AI: Sign up for FeatureBase Cloud today and receive a $300 credit. Join us on Discord if you have any questions.

Understand Serverless Components

Serverless introduces a couple of new components that are important to understand before starting. The first are “workers”. Workers represent the compute for your database and are used for querying and ingesting data. Each worker has a set of pre-defined specifications, which for preview, is 2GB of memory and 1vCPU. This is intentionally small, but workers will evolve to have much larger specs and specific intended workloads (general purpose, ingest-optimized, etc.) coming out of preview.

As you ingest data, your data is stored durably and separate from the workers. In addition to having 11 nines of durability, data is highly available and stored redundantly across multiple locations.

IMPORTANT REMINDER: Functionality is in Preview status, so there are known limitations and likely unknown limitations. A list of known limitations can be referenced as you explore, but please let us know if you encounter any issues. Your feedback is what makes our product better!

Create A Database

The first step to starting with serverless is creating a database. This can be accomplished through the UI by going to the Databases page, choosing Start with a clean database, selecting the Serverless (Preview) option, and pressing CREATE DATABASE:

You will now see your database with a status of RUNNING. One worker is assigned to a new serverless database by default.

Loading and Querying Data

Interacting with a serverless database is the same as other FeatureBase databases. Loading and extracting data is all done through SQL. The following commands can be run to load a couple of records into an iris table that holds flower information:


create table iris (
    _id id,
    sepallength decimal(2),
    sepalwidth decimal(2),
    petallength decimal(2),
    petalwidth decimal(2),
    species string
) COMMENT 'table holding flower information'

BULK INSERT
INTO iris (_id, sepallength, sepalwidth, petallength, petalwidth, species)
MAP('id' ID,
'sepalLength' DECIMAL(2),
'sepalWidth' DECIMAL(2),
'petalLength' DECIMAL(2),
'petalWidth' DECIMAL(2),
'species' STRING)
FROM
x'{"id": 1, "sepalLength": "5.1", "sepalWidth": "3.5", "petalLength": "1.4", "petalWidth": "0.2", "species": "setosa"}
{"id": 2, "sepalLength": "4.9", "sepalWidth": "3.0", "petalLength": "1.4", "petalWidth": "0.2", "species": "setosa"}
{"id": 3, "sepalLength": "4.7", "sepalWidth": "3.2", "petalLength": "1.3", "petalWidth": "0.2", "species": "setosa"}'
WITH
    FORMAT 'NDJSON'
    INPUT 'STREAM';

select * from iris

Scaling Your Database 

Now you may want to load something larger and want to load it quickly. You can add a worker to your database with a simple SQL query:


ALTER DATABASE serverless-db WITH WORKERS 2;

After running this query, another 2GB worker is added to your database and available to use for queries you issue. Let’s create and load a new table with more data following this guide.

After following the guide and loading a larger dataset, you can remove workers from your database. In fact, you can remove all of the workers, which may be helpful if you don’t run queries outside of business hours and don’t want to pay for idle compute:


ALTER DATABASE serverless-db WITH WORKERS 0;

When you do this, you will no longer be able to issue queries to your database. Don’t worry, the data you loaded is safe on disk and will be available for reads/write whenever you add workers back.

Dropping Your Database

If you are done with a database and no longer want the data in any of the tables, you can drop your database. This action cannot be undone and will result in all data being deleted permanently:


DROP DATABASE serverless-db;

We hope you are as excited as we are about FeatureBase Serverless and the many advantages it can bring! We’ll be continuously pushing updates and new features, so make sure and stay tuned in! For more information on serverless, check out our docs, or for getting access, please contact FeatureBase Support on Discord.

SCHEDULE A DEMO