Skip to main content

Overview

Fly.io deploys LiteLLM containers close to your users in 30+ regions worldwide, providing:
  • Low latency: Edge compute near users
  • Global distribution: Automatic multi-region deployment
  • Auto-scaling: Scale based on demand
  • Private networking: WireGuard-based secure networking

Quick Start

1

Install Fly CLI

2

Login to Fly

3

Clone LiteLLM

4

Launch Application

Fly will:
  • Detect Dockerfile
  • Create fly.toml configuration
  • Prompt for region selection
  • Ask to create PostgreSQL database
5

Set Environment Variables

6

Deploy

Configuration File

Create fly.toml

Fly CLI generates a basic config, but customize for LiteLLM:
fly.toml

Multi-Region Deployment

Deploy to multiple regions for global coverage:
Deploy:
Fly.io routes requests to the nearest region automatically using Anycast DNS.

Database Setup

Fly PostgreSQL

1

Create Database Cluster

Options:
  • Regions: Deploy in 2-3 regions for HA
  • VM size: shared-cpu-1x, shared-cpu-2x, performance-1x
  • Volume: 10GB minimum, scales as needed
2

Attach Database to App

This sets DATABASE_URL environment variable automatically.
3

Verify Connection

Database Replication

For multi-region HA:
Configure read replicas:

Private Networking

Fly.io provides private IPv6 networking via WireGuard:

Connect Services

Connection strings:

Connect External Services

For managed services (AWS RDS, etc.), use Fly Proxy:

Configuration File Deployment

Method 1: Bake into Image

Add to Dockerfile:

Method 2: Fly Secrets

Store config as secret:
Update entrypoint to decode:

Method 3: Fly Volumes

Volumes are region-specific and not replicated. Use for local data only.

Secrets Management

Set Secrets

secrets.txt:

View Secrets

Custom Domains

1

Add Certificate

2

Get DNS Records

Shows required DNS records (CNAME or A/AAAA).
3

Update DNS

Add to your DNS provider:
4

Verify

Fly automatically provisions SSL certificate.

Scaling

Autoscaling Configuration

fly.toml

Manual Scaling

Resource Presets

Monitoring and Metrics

Fly Metrics

Prometheus Integration

Expose metrics to Fly’s Prometheus:
fly.toml
Access metrics:

External Monitoring

Add observability providers:

Deployment Strategies

Blue-Green Deployment

Canary Deployment

Rolling Deployment (Default)

High Availability Setup

Multi-Region with Load Balancing

fly.toml
Deploy:

Health Checks

Cost Optimization

Pricing Overview

Free Allowance

Optimization Tips

1

Use Autoscaling

Stop machines when idle:
2

Right-Size Resources

Start small, scale up based on metrics:
3

Use Regional Routing

Deploy only in regions with actual traffic.
4

Optimize Images

Use multi-stage builds, minimize layers:

Troubleshooting

Deployment Failures

Database Connection Issues

SSH into Machine

Restart Machines

Security Best Practices

Network Security

fly.toml

Secrets Rotation

Private Networking

Next Steps

Monitoring

Set up comprehensive observability

High Availability

Multi-region HA deployment patterns

Security

Harden your deployment

Performance

Optimize for global traffic