Skip to main content
Deployment is the process of taking your application from your development machine and making it available on the internet for users to access. This involves building your code, configuring it for a production environment, and running it on a server that’s always online. This section covers everything you need to deploy Mizu applications to production. Whether you’re deploying to a VPS (Virtual Private Server), Kubernetes cluster, or serverless platform, you’ll find detailed guides for your environment.

Building for Production

When you develop locally, you run your app with go run. But for production, you need to compile your code into an executable file (called a binary) that can run on your server without needing Go installed. Go compiles your application into a single binary with no external dependencies. Unlike languages that need a runtime (like Python or Node.js), Go bundles everything into one file. This makes deployment remarkably simple—just copy the file to your server and run it.

Basic Build

Optimized Production Build

For production, you want a smaller, faster binary. You also need to specify which operating system and CPU architecture the binary should run on. This is called cross-compilation—building on your Mac or Windows machine for a Linux server.
Here’s what each flag does:

Common Architectures

Deployment Decision Guide

Choose your deployment method based on your needs:

Essential Configuration

Environment Variables

Read configuration from environment variables for flexibility:

Common Environment Variables

Configuration Pattern

Health Checks

In production, your application runs alongside infrastructure that monitors its status. Health checks are special endpoints that answer a simple question: “Is this application working properly?” Load balancers use health checks to decide which servers should receive traffic. If your app becomes unhealthy (maybe the database connection dropped), the load balancer stops sending requests to it until it recovers. Orchestrators like Kubernetes use health checks to automatically restart containers that have crashed or become unresponsive. Mizu provides built-in health check handlers that work with all major platforms:

Custom Health Checks

Graceful Shutdown

When you need to update your application or restart the server, you don’t want to abruptly kill connections—that would interrupt users mid-request, potentially losing data or causing errors. Graceful shutdown solves this by giving active requests time to complete before the server stops. Here’s what happens: when your server receives a shutdown signal (like when you press Ctrl+C or when Kubernetes scales down), it stops accepting new requests but waits for current requests to finish. This ensures users don’t experience sudden disconnections. Mizu handles graceful shutdown automatically. You can configure how long to wait for active requests:

Shutdown Process

  1. Server receives SIGINT or SIGTERM
  2. /readyz starts returning 503
  3. Server stops accepting new connections
  4. Active requests complete (up to timeout)
  5. Server exits cleanly

Logging in Production

During development, you want human-readable logs that are easy to scan visually. But in production, your logs are consumed by machines—log aggregation systems that collect, search, and alert on your application’s output. These systems work best with structured JSON logs, where each log entry is a JSON object with consistent fields. JSON logs enable powerful queries like “show me all errors from the payment service in the last hour” or “find requests that took longer than 500ms.” This would be difficult with plain text logs. Configure structured JSON logging for production:

Log Aggregation

In production, send logs to a centralized system:

Security Checklist

Production environments are exposed to the internet, which means your application will face automated attacks, vulnerability scanners, and potentially malicious users. Security isn’t optional—it’s a core requirement for any public-facing application. The good news is that most security measures are straightforward to implement. Here’s a checklist of essential security practices to complete before deploying:
  • HTTPS only - Use TLS via reverse proxy or load balancer
  • Security headers - Use the helmet middleware
  • Rate limiting - Protect against abuse
  • Input validation - Validate all user input
  • Secrets management - Never commit secrets to git
  • Minimal permissions - Run as non-root user
  • Dependencies - Keep dependencies updated
  • Error messages - Don’t expose internal errors to users

Security Middleware

Monitoring

Once your application is running in production, you need visibility into how it’s performing. Monitoring collects metrics like request counts, response times, and error rates. This data helps you answer questions like “Is my app getting slower?” or “Did that deployment cause more errors?” Without monitoring, you’re flying blind—you won’t know about problems until users complain. With proper monitoring, you can set up alerts to notify you before small issues become outages.

Prometheus Metrics

Prometheus is the most popular open-source monitoring system. It collects metrics by periodically “scraping” a /metrics endpoint that your app exposes. Here’s how to add it:

Key Metrics to Monitor

Next Steps

Docker

Container deployment with Docker.

Kubernetes

Orchestration with Kubernetes.

Cloud Platforms

AWS, GCP, DigitalOcean, and more.

Traditional

VPS with systemd and reverse proxy.