This guide explains how to deploy the LLM Performance Simulator application in production environments.
Docker is the recommended deployment method for production environments because it:
- Encapsulates all dependencies
- Ensures consistency between development and production
- Simplifies scaling and management
- Provides better security through containerization
# Build the Docker image
docker build -t budsimulator .
# Run the container
docker run -d \
--name budsimulator \
-p 8000:8000 \
-p 3000:3000 \
budsimulatorFor a more production-ready setup with separate services:
# Start all services
docker-compose -f docker-compose.prod.yml up -d
# View logs
docker-compose -f docker-compose.prod.yml logs -f
# Stop services
docker-compose -f docker-compose.prod.yml downFor deploying to a specific domain like simulator.bud.studio:
# Use the domain deployment script
./deploy-domain.shThis will:
- Check for existing Docker images
- Build images if needed
- Guide you through SSL certificate setup
- Start services with domain-specific configuration
For production deployments with HTTPS, you'll need SSL certificates. Here are two options:
- Let's Encrypt with Certbot (recommended):
# Install certbot
sudo apt-get update
sudo apt-get install certbot
# Obtain certificates
sudo certbot certonly --standalone -d simulator.bud.studio
# Copy certificates to the ssl directory
sudo cp /etc/letsencrypt/live/simulator.bud.studio/fullchain.pem ssl/
sudo cp /etc/letsencrypt/live/simulator.bud.studio/privkey.pem ssl/
sudo chown $USER:$USER ssl/*.pem- Copy existing certificates:
# Place your certificates in the ssl directory
cp /path/to/your/fullchain.pem ssl/
cp /path/to/your/privkey.pem ssl/If you prefer not to use Docker, you can deploy using a process manager like PM2, but this requires more manual setup.
# Install PM2 globally
npm install -g pm2
# Navigate to the backend directory
cd BudSimulator
# Start the backend API
pm2 start run_api.py --name "budsimulator-backend" --interpreter python
# Save the PM2 configuration
pm2 saveFor the frontend, you would need to:
- Build the React application
- Serve it with a web server like Nginx
# Build the frontend
cd BudSimulator/frontend
npm run build
# Serve with a web server (example with serve)
npx serve -s build -l 3000The application uses SQLite by default. For production, you might want to:
- Use a persistent volume for the database file
- Consider migrating to PostgreSQL for better performance
For production deployments, configure SSL/TLS in the nginx configuration:
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /etc/nginx/ssl/certificate.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
# ... rest of configuration
}For high-traffic deployments:
- Use a load balancer in front of multiple instances
- Consider using Redis for session storage
- Use a shared database (PostgreSQL) instead of SQLite
Minimum requirements per instance:
- CPU: 2 cores
- RAM: 4GB
- Disk: 10GB (for dependencies and data)
The Docker image includes a health check:
curl -f http://localhost:8000/api/healthView Docker container logs:
docker logs budsimulatorOr with docker-compose:
docker-compose -f docker-compose.prod.yml logs -fTo update the application:
# Pull the latest code
git pull
# Rebuild and restart containers
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up --build -dRegularly backup the SQLite database:
# In the container
cp /app/BudSimulator/data/prepopulated.db /backup/prepopulated.db.backup
# Or from the host
docker exec budsimulator cp /app/BudSimulator/data/prepopulated.db /backup/prepopulated.db.backupBackup important configuration files:
.envfiles- Custom hardware configurations
- nginx configuration
- Port conflicts: Ensure ports 8000 and 3000 are available
- Permission errors: Check file permissions in volumes
- Database errors: Ensure the database file is accessible
# Check running containers
docker ps
# View container logs
docker logs <container-id>
# Execute commands in container
docker exec -it <container-id> /bin/bash- Run containers as non-root users
- Use environment variables for sensitive configuration
- Regularly update base images
- Implement proper firewall rules
- Use HTTPS in production