tutorial··5 min read·WoWSQL Team

BaaS vs PaaS vs Serverless: Which Backend Model Fits?

BaaS vs PaaS vs serverless explained with the same feature built three ways: what you write, what you run, how each scales and costs, and when to mix them.

BaaS (backend as a service) gives you ready-made backend features such as a database, auth, file storage and an API; PaaS (platform as a service) runs the server code you write; serverless runs individual functions only when a request or event arrives. Most new apps start fastest on a BaaS like WoWSQL, which provides Postgres, auth, a REST API, storage and realtime from $0, and then add serverless functions for the few things that need private server code. Choose PaaS when you need a long-running process, custom protocols or full control of your runtime.

To make the difference concrete, this guide builds the same "create a note" feature three ways and shows what each model asks of you. We ran all three on 29 November 2026 against PostgreSQL 17 with a real PostgREST server and a local stand-in for WoWSQL's auth; the details are in each section.

Key facts

  • BaaS: you write the client and the data rules; the provider runs the database, auth, API and storage. Example: WoWSQL (Free $0, Pro $25/month, Scale $99/month; regions Mumbai, US East and Frankfurt; pricing).
  • Serverless functions: you write one handler per endpoint; the platform starts it per request. AWS Lambda's free tier includes 1 million requests and 400,000 GB-seconds a month, then $0.20 per million requests and $0.0000166667 per GB-second in AWS's examples (Lambda pricing).
  • WoWSQL Compute Functions: Node.js or Python, one file up to 256 KB, a fresh process per request, run in your project's region at /functions/v1/{name}; execution-hour budgets of 5 (Free), 100 (Pro) and 100 (Scale) hours a month per the Compute docs. The pricing page lists Edge Functions under Pro and Scale.
  • PaaS: you write and run a whole server. Example: Render's Free web services spin down after 15 minutes without traffic and take about a minute to wake; Free Postgres databases expire 30 days after creation; paid instances start at $7/month (Render free docs, Render pricing).
  • Mixing is normal: a BaaS for data and auth, functions for webhooks and secret API calls, and a PaaS service only for long-running work.

The three models in one table

BaaS Serverless functions PaaS
You write Client code, schema, access rules One handler per endpoint or event A full server app
You run Nothing Nothing between requests A process that is always on (or sleeps on free tiers)
Auth Built in Bring your own or call the BaaS Bring your own library
Database Included Bring your own (often a BaaS) Bring your own or an add-on
Scaling Provider's job Per request, automatic You pick instance size and count
Long-lived connections Provider's realtime service Usually no Yes
Typical bill Flat plan plus usage Per request and compute time Per instance per month
Lock-in risk Highest (APIs, auth) Medium (handler format) Lowest (standard servers)
Examples WoWSQL, Supabase, Firebase, Appwrite AWS Lambda, WoWSQL Compute Functions Render, Railway, Heroku

Cloudflare's learning center draws the same lines: a BaaS supplies backend features such as auth and push notifications that a PaaS leaves to you, and serverless means event-driven functions that scale without server management (BaaS, PaaS, serverless).

One feature, three ways: "create a note"

All three versions use the same notes table (id, user_id, title, created_at). In the BaaS and serverless versions the table has Row Level Security that allows a user to insert and read only their own notes; the full SQL is in SvelteKit backend with Postgres.

1. BaaS: call the generated API from your app

// 1) BaaS: the app calls the generated REST API directly; RLS does the authorization
const WOWSQL_URL = process.env.WOWSQL_URL          // https://myproject.wowsqlconnect.com
const ANON_KEY = process.env.WOWSQL_ANON_KEY       // wowsql_anon_... (safe in client code)

export async function createNote(accessToken, title) {
  const res = await fetch(`${WOWSQL_URL}/rest/v1/notes`, {
    method: 'POST',
    headers: {
      apikey: ANON_KEY,
      Authorization: `Bearer ${accessToken}`, // the signed-in user's JWT
      'Content-Type': 'application/json',
      Prefer: 'return=representation',
    },
    body: JSON.stringify({ title }), // user_id defaults to auth.uid(); RLS rejects anything else
  })
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
  return (await res.json())[0]
}

That's the whole backend. There's no server to deploy: the API exists as soon as the table does, and RLS stops anyone writing a note for another user.

Tested: createNote() created a note with a user's token and got 401 without one. On new WoWSQL projects, enable the Data API and expose the table first; otherwise REST calls return 403 DATA_API_DISABLED.

2. Serverless: a WoWSQL Compute Function

Use a function when the logic must stay private, such as calling a paid API with a secret key, verifying a payment webhook, or validating more than a check constraint can.

// 2) Serverless: a WoWSQL Compute Function (Node.js, CommonJS, one file, no packages)
// Store WOWSQL_ANON_KEY as a project secret; WOWSQL_URL is injected for you.
module.exports = async function (event) {
  const input = typeof event.body === 'object' && event.body !== null ? event.body : {}
  const title = String(input.title || '').trim()
  if (title.length < 1 || title.length > 200) {
    return { statusCode: 400, body: { error: 'title must be 1-200 characters' } }
  }
  // Forward the caller's token so Row Level Security still applies
  const res = await fetch(`${process.env.WOWSQL_URL}/rest/v1/notes`, {
    method: 'POST',
    headers: {
      apikey: process.env.WOWSQL_ANON_KEY,
      authorization: event.headers.authorization || '',
      'content-type': 'application/json',
      prefer: 'return=representation',
    },
    body: JSON.stringify({ title }),
  })
  const text = await res.text()
  return { statusCode: res.status, body: text ? JSON.parse(text) : null }
}

Call it at https://myproject.wowsqlconnect.com/functions/v1/create-note with the user's Authorization: Bearer token. The runtime gives you fetch and built-in modules only (no npm installs), and nothing in memory survives between requests.

Tested: we loaded this exact file with Node.js and called it with WoWSQL-style event objects. It returned 201 with the new row for a signed-in user and 400 for an empty title. We did not deploy it to the WoWSQL runtime.

3. PaaS: your own Express server

// 3) PaaS: your own long-running Express server, deployed to any Node.js host
import express from 'express'
import pg from 'pg'

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
const app = express()
app.use(express.json())

app.post('/notes', async (req, res) => {
  const userId = await verifyUser(req.get('authorization')) // you write and maintain auth
  if (!userId) return res.status(401).json({ error: 'sign in first' })
  const title = String(req.body?.title ?? '').trim()
  if (title.length < 1 || title.length > 200) return res.status(400).json({ error: 'title must be 1-200 characters' })
  // Apps usually connect as the table owner, which skips RLS: filtering by user is on you
  const { rows } = await pool.query(
    'insert into notes (user_id, title) values ($1, $2) returning id, title, created_at',
    [userId, title],
  )
  res.status(201).json(rows[0])
})

app.listen(process.env.PORT || 3000)

async function verifyUser(header) {
  // Placeholder: check a session or JWT with the auth library you choose
  return header === `Bearer ${process.env.TEST_TOKEN}` ? process.env.TEST_USER_ID : null
}

You now own authentication, connection pooling, input validation, deploys, logs and uptime. In return you can do anything: hold WebSocket connections, run queues, use any npm package, and move hosts freely.

Tested with Express 5.3.0: the 401 and 400 paths behaved as written. The insert itself was rejected in our test database because that notes table has RLS and our test role isn't the owner, which is the point of the comment in the code: in the usual PaaS setup, your server connects as the table owner and RLS no longer protects you.

How the costs behave

WoWSQL (BaaS) AWS Lambda (serverless) Render (PaaS)
Free $0: 1 project, 256 MB database, 10,000 MAU, 5 GB bandwidth 1M requests + 400,000 GB-s per month Web service spins down after 15 min idle; 750 free instance hours a month; Postgres expires after 30 days
First paid step Pro $25/month: dedicated Postgres, 10 GB database, 100,000 MAU, daily backups (7 days) $0.20 per 1M requests + $0.0000166667 per GB-s Instances from $7/month (512 MB RAM)
What grows the bill MAU above plan, storage and transfer overages Requests × duration × memory Bigger or more instances, databases priced separately
Includes auth and DB Yes No No

Prices read on 29 November 2026 from WoWSQL pricing, AWS Lambda pricing and Render pricing. Check the live pages before deciding; Lambda prices vary by region and architecture.

Where others are better: Lambda's free request allowance is generous and pay-per-use is hard to beat for spiky, low-volume jobs. A PaaS like Render gives you any language, long-running processes and the least lock-in. WoWSQL Compute Functions are deliberately small (one file, no packages, a 10-second timeout on Free and 60 seconds on paid plans), so heavy jobs belong elsewhere. A BaaS wins when you'd otherwise spend weeks building auth, an API and access control yourself.

Which should you choose?

  • Building an MVP, mobile app or SaaS dashboard? Start with a BaaS. See Backend for an MVP and Do I need a backend?.
  • Need webhooks, payments or secret API keys? Add serverless functions next to your BaaS.
  • Need WebSockets you control, background workers, ML models or a custom protocol? Run that part on a PaaS, and keep auth and data in the BaaS if you like.
  • Need total control or strict self-hosting? A PaaS or your own servers, possibly with a self-hosted BaaS.
  • Worried about lock-in? Prefer a Postgres-based BaaS: your data stays in standard Postgres you can dump and move, as described in Supabase to WoWSQL migration.

Related guides

FAQ

What is the difference between BaaS and PaaS?

A BaaS gives you finished backend features (database, auth, storage, an API) that you configure and call. A PaaS gives you a place to run code you write yourself. With WoWSQL, a BaaS, you create a table and get a REST API with auth; with a PaaS like Render you write and deploy the server that provides those things.

Is serverless the same as backend as a service?

No. Serverless functions run your own code per request without you managing servers; a BaaS provides ready-made services. They overlap because many BaaS platforms, including WoWSQL, also offer serverless functions for custom logic.

Is Firebase a BaaS or a PaaS?

Firebase is usually called a BaaS: it provides auth, databases, storage and hosting as services, plus Cloud Functions for serverless code. WoWSQL and Supabase are Postgres-based BaaS platforms in the same category.

When should I not use a backend as a service?

When you need long-running processes, custom network protocols, unusual databases, full control over the runtime, or strict self-hosting. Also be careful if your access rules are too complex to express as database policies.

Which is cheapest for a small app: BaaS, PaaS or serverless?

For most small apps a BaaS free tier costs nothing and includes auth and a database, while serverless and PaaS still need a database somewhere. Serverless is cheap for occasional jobs; PaaS free tiers often sleep when idle.

Can I combine BaaS and serverless functions?

Yes, and it's the common pattern: the app talks to the BaaS directly for data and auth, and a few functions handle webhooks, payments or calls that need a secret. WoWSQL Compute Functions run next to your project and can call its REST API.

Create a free WoWSQL project · Compute Functions docs · Pricing