Skip to main content

Overview

This guide shows you how to instruct AI coding agents (Claude, ChatGPT, Cursor, etc.) to implement UltraBalancer in your infrastructure.

Installation Prompt

Use this prompt to have an AI agent install UltraBalancer:
Install UltraBalancer load balancer on Ubuntu 22.04 server:

1. Install Rust toolchain and dependencies
2. Clone https://github.com/bas3line/ultrabalancer.git  
3. Build with cargo build --release
4. Install to /usr/local/bin/ultrabalancer
5. Verify with ultrabalancer --version

Please execute these commands and show me the output.

Configuration Prompt

Use this to generate a configuration file:
Create a UltraBalancer configuration file at /etc/ultrabalancer/config.yaml:

- Listen on port 80
- Backend servers: 192.168.1.10:8080, 192.168.1.11:8080, 192.168.1.12:8080
- Use round-robin algorithm
- Enable health checks every 5 seconds
- Maximum 3 failures before marking server down

Generate the complete YAML configuration file.

Systemd Service Prompt

Create a systemd service for UltraBalancer:

1. Create service file at /etc/systemd/system/ultrabalancer.service
2. Run as user 'ultrabalancer'
3. Use config file /etc/ultrabalancer/config.yaml
4. Auto-restart on failure
5. Enable on boot
6. Start the service and show status

Execute all steps.

Docker Deployment Prompt

Create a Docker Compose setup for UltraBalancer:

1. Use image: ghcr.io/bas3line/ultrabalancer:latest
2. Map port 80 to container port 8080
3. Mount config.yaml file
4. Include 3 nginx backend containers
5. Create custom network
6. Start with docker-compose up -d

Generate the docker-compose.yml file and start the services.

Kubernetes Deployment Prompt

Create Kubernetes manifests for UltraBalancer:

1. ConfigMap with configuration
2. Deployment with 2 replicas  
3. Service (LoadBalancer type)
4. Health check probes
5. Apply all manifests

Generate all YAML files and apply to cluster.

Testing Prompts

Basic Health Check

Test UltraBalancer is working:

1. Check health endpoint: curl localhost/health
2. Check metrics: curl localhost/metrics  
3. Send 10 test requests
4. Verify requests are distributed across backends

Show all outputs.

Failover Testing

Test UltraBalancer failover:

1. Check current health status
2. Kill one backend server
3. Wait 10 seconds
4. Check health status again (should show degraded)
5. Send 10 requests (should only go to healthy backends)
6. Restart the backend
7. Verify it recovers

Show all outputs and verify failover works.

Load Testing

Performance test UltraBalancer:

1. Install Apache Bench (ab)
2. Run: ab -n 10000 -c 100 http://localhost/
3. Check metrics endpoint
4. Report: requests/sec, response time, failures

Show results and analysis.

Common Scenarios

Add a new backend server to UltraBalancer:

1. Edit /etc/ultrabalancer/config.yaml
2. Add new backend: 192.168.1.20:8080 with weight 100
3. Reload service: sudo systemctl reload ultrabalancer
4. Verify backend is healthy
5. Test traffic distribution

Show updated config and verification.
Change load balancing algorithm to least-connections:

1. Edit config file
2. Change algorithm field  
3. Restart service
4. Send test requests
5. Verify new distribution

Show before/after metrics.
Setup Prometheus monitoring for UltraBalancer:

1. Install Prometheus
2. Configure scrape endpoint
3. Restart Prometheus  
4. Verify metrics collection
5. Create basic dashboard

Show Prometheus config and verify data collection.
Harden UltraBalancer for production:

1. Create dedicated user
2. Set file permissions
3. Configure resource limits
4. Setup log rotation
5. Configure firewall rules
6. Enable systemd hardening

Apply all hardening steps and verify.

Complete Deployment Example

Use this comprehensive prompt for full deployment:
Deploy UltraBalancer on Ubuntu 22.04 production server:

Repository: https://github.com/bas3line/ultrabalancer

Requirements:
- Build from source using Rust/Cargo
- Install to /usr/local/bin
- Config: /etc/ultrabalancer/config.yaml
- Listen on port 80
- Backends: 10.0.1.10:8080 (weight 200), 10.0.1.11:8080 (weight 100)
- Use least-connections algorithm
- Health checks every 5 seconds
- Run as systemd service
- Start on boot
- Run as unprivileged user

Steps:
1. Install dependencies
2. Build and install
3. Create user and directories
4. Create configuration
5. Create systemd service
6. Configure firewall
7. Start and verify

Show output of: ultrabalancer --version, curl localhost/health, curl localhost/metrics

Tips for AI Agents

Be specific about paths, ports, and configuration values in your prompts.
Always ask AI to verify installation with version check and health endpoints.
Request AI to show full error messages if something fails.
Include the repository URL in prompts: https://github.com/bas3line/ultrabalancer

Next Steps