Production Checklist
Before deploying TrailBase to production, ensure you’ve completed these essential steps:1
Set a public URL
Configure the public URL for OAuth redirects and email links:Or via environment variable:
2
Bind to the correct address
For production behind a reverse proxy:For direct internet exposure, bind to localhost and use a reverse proxy:
3
Configure CORS
Restrict CORS origins to your domains:
4
Set up SMTP for emails
Configure email delivery for auth verification and password resets. Edit
traildepot/config.textproto:5
Review authentication settings
Adjust token TTLs in
config.textproto:6
Set up SSL/TLS
Use a reverse proxy (nginx, Caddy, Traefik) for SSL/TLS termination. Never expose TrailBase directly to the internet without HTTPS.
7
Configure backups
Implement automated backups of the data directory (see Backup Strategies below).
8
Set up monitoring
Implement health checks and monitoring (see Monitoring section below).
Security Best Practices
SSL/TLS Configuration
Always run TrailBase behind a reverse proxy with SSL/TLS:File Permissions
Secure the data directory with proper permissions:Secrets Management
TrailBase separates configuration into two files:config.textproto- Non-sensitive configurationsecrets.textproto- Sensitive values (OAuth secrets, SMTP passwords)
[(secret) = true] in the protobuf schema are automatically redacted to <REDACTED> in config.textproto and stored in secrets.textproto.
Admin Access
For production, consider separating admin UI access:- Public API to
0.0.0.0:4000(accessible externally) - Admin UI to
127.0.0.1:4001(localhost only)
Rate Limiting
Implement rate limiting at the reverse proxy level:Firewall Configuration
Backup Strategies
Regular backups are essential for production deployments.Full Data Directory Backup
The simplest approach is backing up the entire data directory:SQLite Backup
For online backups without stopping the server, use SQLite’s backup API:Cloud Backup
Sync backups to cloud storage:Restore from Backup
To restore from a backup:Monitoring
Health Check Endpoint
TrailBase provides a health check endpoint:200 OK if the server is healthy.
Uptime Monitoring
Use external monitoring services:- UptimeRobot: Simple HTTP monitoring
- Pingdom: Advanced monitoring with alerting
- Better Uptime: Modern uptime monitoring
- StatusCake: HTTP and performance monitoring
- Monitor URL:
https://yourdomain.com/api/healthcheck - Check interval: 60 seconds
- Alert after: 2 consecutive failures
Log Monitoring
TrailBase stores access and error logs in thelogs.db SQLite database:
Log Retention
Configure log retention inconfig.textproto:
Resource Monitoring
Monitor system resources:- Prometheus + Grafana: Metrics and dashboards
- Netdata: Real-time performance monitoring
- Datadog: Full-stack monitoring
Performance Metrics
Key metrics to monitor:- Request latency: P50, P95, P99 response times
- Request rate: Requests per second
- Error rate: 4xx and 5xx responses
- Database size: Growth rate
- CPU usage: Average and peak
- Memory usage: RSS and growth
- Disk I/O: Read/write operations
Scaling
Vertical Scaling
For most workloads, vertical scaling is the simplest approach:- Small: 1 CPU, 512 MB RAM - Up to 100 req/s
- Medium: 2 CPU, 2 GB RAM - Up to 500 req/s
- Large: 4 CPU, 4 GB RAM - Up to 2000 req/s
- X-Large: 8 CPU, 8 GB RAM - Up to 5000+ req/s
TrailBase is extremely efficient. SQLite’s sub-millisecond latencies mean most applications won’t need horizontal scaling.
Horizontal Scaling (Read Replicas)
For read-heavy workloads:1
Primary instance
Run a single write instance:
2
Create read replicas
Periodically copy the database to read-only instances:
3
Route traffic
Use a load balancer to route:
- Writes → Primary instance
- Reads → Read replicas (round-robin)
CDN for Static Assets
If serving static files:- Cache static assets globally
- Reduce load on TrailBase
- Improve latency for users worldwide
Database Optimization
Optimize SQLite performance:Systemd Service
Run TrailBase as a systemd service:/etc/systemd/system/trailbase.service
Troubleshooting
High CPU Usage
Check for:- Expensive queries (add indexes)
- Too many realtime subscriptions
- Insufficient
runtime-threadsfor WASM workloads
Database Locked
SQLite allows one writer at a time:- Enable WAL mode (enabled by default in TrailBase)
- Reduce write transaction duration
- Consider read replicas for read-heavy loads
Memory Leaks
Monitor memory over time:- TrailBase version
- Memory growth rate
- Request patterns
- Configuration
Next Steps
Configuration
Detailed configuration options and environment variables
Self-Hosting
Learn about different deployment strategies