Skip to main content

Write business logic,
let the platform run it.

Serverless functions for events and schedules; CloudRun containers for full web services, any language, and long connections. Both connect to CloudBase resources.

Function · Container · Revision
compute / deploymentshealthy
order-service
function

create-order

Node.js · HTTP · LATEST

function

daily-report

Node.js · timer · v3

cloudrun

realtime-api

Container · WebSocket · 002

time · requestresourcestate
10:42:31 · req_81d2create-order200 · 84ms
10:42:28 · req_81c9realtime-apiconnected
02:00:00 · timer_42daily-reportcompleted
One request, visible end to end

From trigger to resource access — context at every step

Request ID, revision, and stdout follow execution so you can see what happened in which function or container.

request executionobservable
01 · Trigger

Request enters compute layer

SDK · HTTP · Timer

02 · Execute

Run function or container

Node.js Function · CloudRun

03 · Connect

Access backend resources

Database · storage · external APIs

signalvaluestate
request_idreq_81d2traced
revisionorder-service@3stable
stdoutorder createdcollected

Functions for small jobs, containers for full services

Pick compute by workload — you don't need one runtime for every backend concern.

01

Node.js cloud functions

CommonJS entry handles event and context; compose database, storage, and third-party services via NPM.

FUNCTION
02

Event and timer triggers

Trigger via SDK, HTTP, or seven-field Cron — same runtime for requests and background jobs.

TRIGGER
03

HTTP access

Configure HTTP access, custom paths, and domains; return JSON or custom integration responses.

HTTP
04

Versions and gradual rollout

Publish immutable versions; shift traffic between LATEST and stable revisions to validate safely.

REVISION
05

CloudRun containers

Deploy containerized CloudRun when you need any language, full frameworks, long connections, or multi-process apps.

CONTAINER
06

Logs and monitoring

Trace stdout, invocations, latency, HTTP errors, and resource usage by request and revision.

OBSERVABILITY
Serverless isn't about hiding code — it's about moving focus from server lifecycles back to requests, revisions, and business outcomes.
Product design principle
Fit the workload

Not functions vs containers — the right tool for each job

Functions handle short event-driven work; CloudRun handles full frameworks, streaming, and long-lived connections.

Compare compute options
CHOOSE A RUNTIME
event taskNode.js cloud functions
scheduled jobTimer triggers
web serviceCloudRun containers
long connectionSSE / WebSocket

From a function to a sustainably released service

Examples focus on documented Node.js functions, timer triggers, and Docker containers in this repo.

Node.js function

Handle business requests with event and context

index.js exports an async main; event carries trigger data, context provides request and execution context.

  • CommonJS as the default entry convention
  • NPM for third-party dependencies
  • Return value becomes the invocation result
index.js
// index.js
exports.main = async (event, context) => {
  const { sku, quantity = 1 } = event

  const order = await createOrder({
    sku,
    quantity,
    requestId: context.requestId
  })

  return {
    ok: true,
    orderId: order.id
  }
}
Timer trigger

Describe recurring jobs with seven-field Cron

Configure reports, cleanup, or sync as timer triggers — no dedicated scheduler process.

  • One function can have multiple triggers
  • Trigger names are unique within a function
  • When day and weekday are both set, either match fires
config.json
{
  "triggers": [
    {
      "name": "daily-report",
      "type": "timer",
      "config": "0 0 2 * * * *"
    }
  ]
}
CloudRun container

Ship the full runtime with a Dockerfile

When you need any language version, a full web framework, or long connections, define deps and startup in a container.

  • App listens on the configured PORT
  • Stdout goes to service logs
  • Service, revision, and instance form the resource hierarchy
Dockerfile
FROM node:22-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev

COPY . .
ENV PORT=8080
EXPOSE 8080

CMD ["node", "server.js"]
Compute ecosystem

One compute layer for different backend workloads

Events, APIs, background jobs, and full services can run close to CloudBase data and identity.

01

Event jobs

Data processing, notifications, and resource callbacks.

02

API services

HTTP endpoints, webhooks, and third-party integrations.

03

Container apps

Full frameworks, streaming responses, and long connections.

Node.jsNPMHTTPTimerCronVersionGradual rolloutDockerfileCloudRunSSEWebSocketLogs & monitoring
Run your backend

Match the workload, then pick the runtime

Start with your first cloud function, or bring existing container services to CloudRun.