Skip to main content
Serverless computing is a cloud model where you don’t manage any servers at all. You upload your code, and the platform handles everything: provisioning machines, scaling up during traffic spikes, scaling down to zero when idle, and even patching security updates. You only pay for the actual compute time your code uses. The term β€œserverless” is a bit misleadingβ€”there are still servers, you just don’t see or manage them. It’s like electricity: you don’t maintain a power plant, you just use what you need and pay for consumption. This guide covers deploying Mizu applications to AWS Lambda, Google Cloud Functions, and other serverless environments.

Understanding Serverless with Go

Serverless platforms work differently from traditional servers. Understanding these characteristics helps you design better serverless applications: Why Go is great for serverless: Go’s compiled binary starts in ~50ms (compared to 500ms+ for Java or 200ms+ for Node.js), making cold starts much less painful. Go also uses little memory, which reduces costs since you pay for memory usage.

AWS Lambda

AWS Lambda is the original and most popular serverless platform. You upload a function, and AWS runs it in response to eventsβ€”HTTP requests, database changes, file uploads, or scheduled triggers. For web applications, you need a way to receive HTTP requests. AWS offers two options: Function URLs (simpler, direct HTTP access) or API Gateway (more features like rate limiting, API keys, and request transformation).

Lambda with Function URLs

Function URLs are the simplest way to invoke Lambda via HTTP. AWS gives you a URL like https://xyz123.lambda-url.us-east-1.on.aws/ that directly invokes your function. No API Gateway setup required. main.go:
Build and deploy:

Lambda with API Gateway

For more control over HTTP handling. template.yaml (AWS SAM):
Deploy with SAM:

Using aws-lambda-go-api-proxy

A library that simplifies Lambda + Mizu integration:

Google Cloud Functions

Google Cloud Functions is Google’s serverless platform. It’s tightly integrated with other Google Cloud services and has a simpler deployment model than Lambdaβ€”you can deploy directly from source code without building a container.

HTTP Function

The simplest approach is an HTTP-triggered function. Your function receives standard http.ResponseWriter and *http.Request parameters, so Mizu works seamlessly: function.go:
Deploy:
Based on Cloud Run, better performance.

Azure Functions

main.go:
host.json:
function.json:

Vercel

Vercel supports Go with their Serverless Functions. api/index.go:
vercel.json:

Optimizing for Serverless

Serverless performance is all about reducing cold starts and minimizing execution time (since you pay per millisecond). These optimizations can significantly reduce costs and improve user experience.

Reduce Cold Start Time

Cold starts happen when there’s no warm instance available to handle your request. The key insight is that initialization code runs once per instance, not once per request. Put expensive setup (like database connection pools) in init() so it only runs during cold starts:

Keep Connections Alive

Binary Size Optimization

Comparison

When to Use Serverless

Good for:
  • Variable/unpredictable traffic
  • Event-driven workloads
  • Cost optimization at low scale
  • APIs with bursty traffic
Avoid for:
  • Long-running processes
  • WebSocket connections
  • High-volume, consistent traffic
  • Latency-sensitive applications

Next Steps

Traditional Deployment

VPS with systemd and reverse proxy.

CI/CD

Automate serverless deployments.