Introducing SingleStore Cloud Functions: Serverless Data APIs in Aura Container Service

Our engineering and product teams are super excited to roll out SingleStore Cloud Functions to public preview. 

Introducing SingleStore Cloud Functions: Serverless Data APIs in Aura Container Service

This new feature empowers users to transform SingleStore Notebooks into production-ready REST APIs with minimal configuration that seamlessly leverage the speed and scale the SingleStore database offers.

what-are-singlestore-cloud-functionsWhat are SingleStore Cloud Functions?

SingleStore Cloud Functions are serverless compute instances that allow developers to expose Python functions written in notebooks as REST API endpoints. Built on our Aura Container Service, this feature enables you to create high-performance data APIs that communicate seamlessly with the SingleStore database.

Unlike traditional serverless offerings, SingleStore Cloud Functions are designed specifically for real-time, data-intensive workloads, with pre-warmed containers colocated with SingleStore to help minimize latency and maximize performance. This approach allows you to focus on building intelligent applications without worrying about infrastructure management, scaling or deployment complexities.

why-singlestore-cloud-functionsWhy SingleStore Cloud Functions?

seamless-database-integrationSeamless database integration

Aura Container Service is designed to run in close proximity (ideally co-located) to the distributed SingleStore database engine, providing optimized communication channels that significantly reduce latency. This architecture enables Cloud Functions to interact with your database at speeds that are difficult to achieve with traditional serverless platforms hosted on separate infrastructure.

solve-the-static-endpoint-challengeSolve the static endpoint challenge

While our Aura notebooks allow users to execute SingleStore SQL commands from within the portal, the on-demand nature of container provisioning made it challenging to establish fixed endpoints for external application integration. Cloud Functions solve this problem by providing dedicated, persistent URLs for your functions, allowing external applications to reliably access your data services.

focus-on-logic-not-infrastructureFocus on logic, not infrastructure

Users can go from interactive/development experience through notebooks to a deployed/published experience in a click of a button. By abstracting away the complexities of container orchestration, networking and scaling, Cloud Functions let you concentrate on what matters most: writing code that delivers value to your end users. You no longer need to worry as much about storage management, versioning or infrastructure maintenance — now your data, apps, compute and storage are all within the secure boundary of SingleStore.

key-features-of-singlestore-cloud-functionsKey features of SingleStore Cloud Functions

instant-container-availabilityInstant container availability

Leveraging Aura's pre-warmed container pool architecture, Cloud Functions responds to requests in under 500 milliseconds, even for "cold" starts. This performance is achieved through our innovative container pooling system that maintains ready-to-use containers, eliminating the typical delay associated with spinning up new instances. JWT-based authentication ensures only authorized users can access your deployed endpoints.

gpu-supportGPU support

For compute-intensive AI applications, Cloud Functions provide access to GPU-accelerated containers with pre-installed NVIDIA drivers, making it seamless to run machine learning workloads alongside your database operations.

simplified-developer-experienceSimplified developer experience

Get seamless integration with any SingleStore workspace under the hood. The platform eliminates Docker and Kubernetes complexity, handling container orchestration automatically so developers can focus purely on their application code — rather than infrastructure concerns.

how-to-create-your-first-cloud-functionHow to create your first Cloud Function

Creating a Cloud Function in SingleStore is straightforward. Let's walk through a simple, template example: building a data API.

template-from-our-notebook-spacesTemplate from our Notebook Spaces

Import the template notebook directly from our Spaces page.

template-from-new-notebook-creation-flowTemplate from new notebook creation Flow

We currently only allow Cloud Functions to be created for shared notebooks, so be sure to choose a shared location for yours.

understanding-the-structure-of-the-cloud-function-notebookUnderstanding the structure of the Cloud Function notebook

In the template, we will set up a table where we will define Cloud Functions to perform basic CRUD operations through REST APIs.  

Step 1. Optionally setup your database and table

For the first run, set up the required SingleStore tables in the connected database. Remove this SQL notebook cell before publishing the cloud function after initial setup.

1DROP TABLE IF EXISTS items;2
3CREATE TABLE IF NOT EXISTS items (4   id INT PRIMARY KEY,5   name VARCHAR(255),6   price FLOAT7);

Step 2. Structure a Cloud Function

Create a connection pool and set up the environment with needed imports. Most of this portion will be boilerplate code.

Define the data structure that will be the unit

This is the base record that will be read, written and transmitted from database to Cloud Functions, then to the caller

1# Define the Type of the Data Unit2class Item(BaseModel):3   id: int4   name: str5   price: float

Define FastAPI app

Cloud Functions leverage FastAPI under the hood. Define the CRUD methods as shown here.

1app = FastAPI()2
3# Get all items4@app.get("/items", response_model=list[Item])5async def get_items():6    def get_items_query():7        result = execute_query("SELECT * FROM items;")8        rows = result.fetchall()9        return [{"id": row[0], "name": row[1], "price": row[2]} for row in 10rows]11
12    try:13        return await run_in_thread(get_items_query)14    except Exception as e:15        raise HTTPException(status_code=500, detail=f"Error fetching all items:16{str(e)}")17
18# Insert an item19@app.post("/items", response_model=dict)20async def create_item(item: Item):21    def insert_item_query():22        result = execute_transaction(f"INSERT INTO items (id, name, price)23VALUES ({item.id}, '{item.name}', {item.price})")24        return {"message": f"Item with id {item.id} inserted successfully"}25
26    try:27        return await run_in_thread(insert_item_query)28    except Exception as e:29        raise HTTPException(status_code=500, detail=f"Error while inserting 30item with id {item.id}: {str(e)}")31
32# Get item by id33@app.get("/items/{item_id}", response_model=Item)34async def get_item(item_id: int):35    def get_item_query():36        result = execute_query(f"SELECT * FROM items WHERE id={item_id}")37        row = result.fetchone()38        if not row:39            raise HTTPException(status_code=404, detail="Item not found")40        return {"id": row[0], "name": row[1], "price": row[2]}41
42    try:43        return await run_in_thread(get_item_query)44    except HTTPException as e:45        raise e46    except Exception as e:47        raise HTTPException(status_code=500, detail=f"Error fetching item with 48id {item_id}: {str(e)}")49
50# Delete item by id51@app.delete("/items/{item_id}", response_model=dict)52async def delete_item(item_id: int):53    def delete_item_query():54        result = execute_transaction(f"DELETE FROM items WHERE id={item_id}")55        return {"message": f"number of rows deleted: {result.rowcount}"}56
57    try:58        return await run_in_thread(delete_item_query)59    except Exception as e:60        raise HTTPException(status_code=500, detail=f"Error deleting item with 61id {item_id}: {str(e)}")

Start the FastAPI server

Finally, run the FastAPI server using our python SDK wrapper.

1import singlestoredb.apps as apps2connection_info = await apps.run_function_app(app)

Now, run all the cells in the notebook to deploy a Cloud Function in interactive mode. You will get a temporary URL that will take you to the Swagger UI Cloud Function details page, where you can test the deployed Cloud Function endpoints. You can easily update code, rerunning all cells to quickly redeploy updated Cloud Functions for easy debugging and testing.

Step 3. Publish your Cloud Function

Once you are happy with your notebook code and confirm everything is ready, click the "Publish" button in the top right corner of the notebook view to get a static Cloud Functions endpoint for use.

You'll be prompted to:

  1. Enter a name for your Cloud Function
  2. Provide a description
  3. Select the (optional) SingleStore database connection (for your workspace and database) that your function will connect to
  4. Choose the appropriate compute runtime to run your Cloud Function on
  5. Click “Next” to view the summary and finally, hit “Publish”

After publishing, you should be able to see your Cloud Function with initializing status in your Cloud Functions list page.

Step 4. Viewing the Cloud Functions details page

Select your Cloud Function to view details. On the details page, you will be able to see the following:

  1. Swagger UI showing all the Cloud Functions that are defined in the template
  2. A set of action buttons for triggering the following operations
    1. Copy URL. Copies the unique Cloud Function endpoint URL for use in external apps
    2. App API keys. Used to authenticate external incoming requests with the Aura service
    3. Update. Update the configurable options of the deployed Cloud Function
    4. Share. Specify the RBAC for the current cloud function
    5. Live logs. View the container logs for the deployed Cloud Function to help with debugging in case of unexpected errors and issues
  3. You can test any deployed Cloud Function directly in the Swagger UI

Step 4. Using your Cloud Function

You can now access your Cloud Function using any client that can make standard REST API calls. For example, through curl you would make a request like:

1curl -X 'GET' \2  'https://apps.aws-virginia-nb2.svc.singlestore.com:8000/functions/c2018d87-5506-4a33-a51a-59591c90e96b/items' \3  -H 'accept: application/json' \4  -H "Authorization: Bearer APP_API_KEY"

Visit our Cloud Functions documentation page for more details.

managing-cloud-functionsManaging Cloud Functions

The SingleStore Cloud Portal provides comprehensive management capabilities for your Cloud Functions:

viewing-and-monitoringViewing and monitoring

The Cloud Functions section in the left navigation allows you to view all your deployed functions, live logs and other important details.

updating-functionsUpdating functions

You can update an existing Cloud Function either from the shared notebook or directly from the Cloud Functions page by selecting "Update" from the actions menu.

function-statusFunction status

Functions can have different status indicators:

  • Initializing. The function is being created or updated
  • Active. The function is ready and available for use
  • Idle. The container becomes idle to save on costs when there hasn't been any requests served after a configurable delay

use-cases-for-singlestore-cloud-functionsUse cases for SingleStore Cloud Functions

Now, let’s talk about all the potential places where SingleStore Cloud Functions can be put to work.

real-time-analytics-ap-isReal-time analytics APIs

Build high-performance APIs that deliver real-time analytics directly from your SingleStore database to power dashboards, reports and business intelligence tools.

ai-powered-applicationsAI-powered applications

Combine SingleStore's vector database capabilities with serverless compute to create intelligent applications that leverage machine learning models. With GPU support, you can run inference directly within your Cloud Functions.

data-transformation-servicesData transformation services

Create specialized microservices that transform, enrich or validate data before storing it in SingleStore — all without managing separate infrastructure.

mobile-and-web-application-backendsMobile and web application backends

Build efficient backend services for mobile and web applications that need direct access to your data, with authentication and authorization handled automatically.

future-directions-ai-agent-integrationFuture directions: AI agent integration

In the near future we expect to implement Autoscaling with multiple replicas that scale based on CPU and memory load. We aim to make Cloud Functions a high-performance, efficient feature that is simple to set up, secure by default and easily scalable to handle millions of requests.

We're excited about the future of Cloud Functions, particularly in the AI agent space. We're developing functionality that will allow Cloud Functions to serve either as agents themselves or as tools for agent orchestration frameworks. Check out an example agent we built in one of our hackathons.

This integration will enable complex AI workflows where agents can:

  • Access and manipulate data in SingleStore databases
  • Execute complex business logic
  • Collaborate with other agents to solve sophisticated problems

As we expand Aura to multiple regions to provide our customers with more regions to pick where to deploy their cloud functions. This ensures the deployed Cloud Functions can be colocated with SingleStore Helios for minimal data latency and transfer costs.

SingleStore Cloud Functions represent a significant step forward in our mission. With this feature, SingleStore continues to be an AI data platform that enables developers to build intelligent, data-intensive applications with minimal infrastructure overhead. By combining the power of SingleStore's database capabilities with serverless compute, we're enabling a new generation of applications that deliver insights at unprecedented speed.

We invite you to try Cloud Functions today and experience the future of data API development — where database and compute are seamlessly integrated in a high-performance, fully managed environment.

Try SingleStore free.


Share

Start building with SingleStore