Every time I start a side project, the database is where I slow down. I open the console, and before writing any code, I am picking machine sizes, setting up networking, and doing math on what it will cost if I forget to turn it off over the weekend.
So when Google Cloud announced AlloyDB Express in preview, I wanted to see if it really fixes that. I tried it end to end, and this post is my notes from that run. I will show you every click in the console, from an empty project to a small app running on Cloud Run with AI search. If you follow along, you should stay inside the free tier.
Think of it as a small, quick version of AlloyDB for PostgreSQL. It is meant for prototypes, demos, and AI coding agents that need a database right now, not in ten minutes.
A few things stood out to me when I read the docs:
Here is how it compares to regular AlloyDB:
| AlloyDB Express | AlloyDB | |
|---|---|---|
| Time to create | About 2 seconds | A few minutes |
| Compute | 1 or 2 vCPU, goes to zero when idle | Up to 288 vCPUs, always on |
| Storage | Up to 20 GB | Up to 128 TB |
| High availability | No | Yes |
| Backups | No | Yes |
| SLA | None | 99.99% with regional HA |
| PostgreSQL | 18 only | 14 to 18 |
| Pricing | Pay for what you use, monthly free tier | Hourly compute, 30-day free trial |
You do not need special credits for this. You just need a Google Cloud project with billing turned on.
The free tier gives you 50 compute units and 2 GB of storage every month, per billing account, for the first 12 months. Compute is billed by the second and only while the database is awake. Storage is billed all the time, even when it is asleep, so keep your test data small.
One thing to check early is the region. Right now AlloyDB Express only runs in asia-east1, asia-east2, asia-northeast1, asia-southeast1, australia-southeast1, europe-west2, and us-west1. I am in the US, so I used us-west1, and I put my Cloud Run app there too so the app and the database talk to each other in the same region.
I always do this before trying anything new. It takes one minute and saves you from surprises.
If you created the project yourself, you already have the Owner role, which is enough. If someone else owns it, ask them for the AlloyDB Admin role.
Honestly, this part surprised me. It is three fields and one button.
That is all. The console creates the cluster and a 1 vCPU instance, turns on both public DNS and Private Service Connect for you, and then opens AlloyDB Studio so you can start running SQL.
If your project already has AlloyDB clusters, you will land on the Clusters page instead of Get started. Just click Create cluster in the toolbar and you will see the same three cards.
You can do the same thing from Cloud Shell. One difference: gcloud does not turn on public DNS by default, so I add it on the instance.
gcloud beta alloydb clusters create express-demo \
--region=us-west1 \
--password=YOUR_PASSWORD \
--enable-express \
--project=YOUR_PROJECT_ID
gcloud beta alloydb instances create express-demo-primary \
--cluster=express-demo \
--region=us-west1 \
--instance-type=PRIMARY \
--cpu-count=1 \
--enable-public-dns \
--project=YOUR_PROJECT_ID
The instance has to start at 1 vCPU. If you need more later, you can change it to 2.
AlloyDB Studio is a SQL editor inside the console. I like it for quick tests because you do not have to install psql or open any firewall rules.
If you closed it, here is how to get back:
Now for some data. We will build a tiny product catalog for an outdoor gear shop. Paste this into the Editor 1 tab and click Run:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
description TEXT,
price NUMERIC(10,2),
embedding VECTOR(768)
);
INSERT INTO products (name, description, price) VALUES
('Trail Runner Shoes', 'Lightweight shoes with strong grip for muddy hiking trails', 89.99),
('Rain Shell Jacket', 'Waterproof jacket that packs into its own pocket', 120.00),
('Insulated Water Bottle', 'Keeps drinks cold for 24 hours, great for long hikes', 29.50),
('Camping Lantern', 'Rechargeable LED lantern with three brightness modes', 45.00),
('Wool Hiking Socks', 'Warm, breathable socks that do not cause blisters', 18.00);
SELECT id, name, price FROM products;
You should see five rows at the bottom in the Results pane. At this point I had a working database and had not touched a single network setting.
If you want to use psql or your own SQL tool, the easiest way I found is the gcloud connect command. It encrypts the connection for you, and you do not need to add your IP anywhere:
gcloud beta alloydb connect express-demo-primary \
--cluster=express-demo \
--region=us-west1 \
--public-ip \
--user=postgres \
--database=postgres
If you want to connect with plain psql instead, you first need to allow your IP:
This was the part I was most curious about. With regular PostgreSQL, adding semantic search usually means a separate vector database or an extra pipeline. Here it is just SQL.
You only do this once per project. AlloyDB calls Vertex AI using its own service agent, and that agent needs a role.
service-YOUR_PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com
Give it a few minutes before the next step. The role can take up to 7 minutes to kick in, so if your first embedding call fails with a permission error, just wait a bit and run it again.
Go back to AlloyDB Studio and run this:
CREATE EXTENSION IF NOT EXISTS google_ml_integration CASCADE;
UPDATE products
SET embedding = embedding('text-embedding-005', name || '. ' || description)::vector;
Now every product has a vector of 768 numbers that describes what it is about.
Try a question that does not use any of the words in your product names:
SELECT name, price,
embedding <=> embedding('text-embedding-005', 'something to keep my feet dry and comfy on a long walk')::vector AS distance
FROM products
ORDER BY distance
LIMIT 3;
You should see the socks and the trail shoes near the top, even though the words "dry" and "comfy" are nowhere in the data. That is semantic search in one query.
With five rows you do not need an index. Once you have thousands of rows, add a ScaNN or HNSW index so searches stay fast.
AlloyDB Studio also has Gemini built in. In the editor, click the Gemini (spark) icon and type something like:
Show me all products under 50 dollars, cheapest first
Gemini writes the SQL. Read it first, then click Run. I find this really handy in live demos, and it is the same idea AI coding agents use when they work with your database.
One thing to keep in mind on cost: every embedding() call is a paid Vertex AI request. For a few hundred rows it is pennies, but check the pricing before you embed a big dataset.
A database alone is not much of a demo, so let's add a tiny search API in front of it. I picked Cloud Run because it also scales to zero. When nobody is using the app, neither the app nor the database costs you compute.
At the top right of the console, click the Activate Cloud Shell button (it looks like >_). A terminal opens at the bottom of the page. If you prefer a code editor, click Open Editor in the Cloud Shell toolbar.
Cloud Run runs as the default compute service account unless you choose another one. That account needs two roles. Paste this into Cloud Shell:
PROJECT_ID=$(gcloud config get-value project)
PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format='value(projectNumber)')
SA="$PROJECT_NUMBER-compute@developer.gserviceaccount.com"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SA" --role="roles/alloydb.client"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SA" --role="roles/serviceusage.serviceUsageConsumer"
Make a folder for it:
mkdir express-app && cd express-app
Create a file called requirements.txt:
flask
gunicorn
pg8000
google-cloud-alloydb-connector
Then create main.py:
import os
from flask import Flask, request, jsonify
from google.cloud.alloydbconnector import Connector, IPTypes
app = Flask(__name__)
connector = Connector()
INSTANCE_URI = os.environ["INSTANCE_URI"]
def get_conn():
return connector.connect(
INSTANCE_URI, "pg8000",
user="postgres",
password=os.environ["DB_PASS"],
db="postgres",
ip_type=IPTypes.PUBLIC,
)
@app.get("/search")
def search():
q = request.args.get("q", "")
conn = get_conn()
cur = conn.cursor()
cur.execute(
"""SELECT name, price FROM products
ORDER BY embedding <=> embedding('text-embedding-005', %s)::vector
LIMIT 3""", (q,))
rows = [{"name": r[0], "price": float(r[1])} for r in cur.fetchall()]
conn.close()
return jsonify(query=q, results=rows)
I used the AlloyDB Python connector here. It encrypts the connection and handles auth with IAM, so you do not have to allowlist any IP addresses.
Still inside the express-app folder, run:
gcloud run deploy express-search \
--source . \
--region us-west1 \
--allow-unauthenticated \
--set-env-vars INSTANCE_URI=projects/$PROJECT_ID/locations/us-west1/clusters/express-demo/instances/express-demo-primary,DB_PASS=YOUR_PASSWORD
If it asks to turn on the Cloud Run, Cloud Build, or Artifact Registry APIs, type y. The first deploy takes a few minutes. When it is done, it prints a Service URL.
Open your Service URL in a browser and add a search at the end, like this:
https://express-search-xxxxx.us-west1.run.app/search?q=gear for a rainy hike
You get the top three matching products back as JSON. You can find the app again anytime in the console under Cloud Run, then Services, then express-search.
A small heads up: if the database has been idle for a while, the first request takes around 20 seconds because the instance is waking up. After that it responds normally.
Also, putting the password in an environment variable is okay for a quick test, but not for anything real. For that, move it to Secret Manager or use IAM database authentication.
For a small test like this, the bill should be close to zero:
| Service | What you pay for | Free allowance |
|---|---|---|
| AlloyDB Express | Compute by the second while awake, storage all the time | 50 compute units and 2 GB storage a month, first 12 months |
| Cloud Run | Requests and CPU time | Monthly free tier |
| Vertex AI embeddings | Each embedding() call | No free allowance, but small tests cost pennies |
To keep an eye on usage, open your cluster's Overview page. Under Cluster details, Total storage used shows how much of the 20 GB you have used. The CPU utilization and Active connections charts show compute. For more detail, click System insights in the left menu.
I would not put production data on Express yet. Here is why:
max_connections is fixed at 200, and changing the flag does nothing.
When your prototype is ready to grow up, you can upgrade it in place:
Your data, users, and connection string stay the same, so your app keeps working. Two things to keep in mind: after the upgrade the database no longer scales to zero and is billed at normal AlloyDB rates, and you can't go back to Express. If you are on 1 vCPU in a region that does not support C4A machines, the console will ask you to resize to 2 vCPUs first.
When you are done playing, delete everything so nothing keeps charging you:
Or from Cloud Shell, in one line:
gcloud alloydb clusters delete express-demo --region=us-west1 --force
This is permanent. Express has no backups, so there is no undo.
In one sitting we went from an empty project to a real app: a PostgreSQL database that was ready in seconds, semantic search written in plain SQL, questions in plain English through Gemini, and a Cloud Run API on top. And when nobody uses it, almost all of it goes quiet and stops charging for compute.
It is still a preview, and the limits are real. No backups and a 20 GB cap mean I would keep it to prototypes, hackathons, demos, and agent experiments for now. But for those, it takes away most of the setup pain, and the one-click upgrade means you do not have to start over if the idea works.
If you try it, I would love to hear what you build. Drop it in the comments.
Sources