Skip to main content
This guide covers best practices, optimization strategies, and production considerations for deploying Qwen models at scale.

Architecture Design

Deployment Architecture

Inference Engine

vLLM for production workloads
  • High throughput
  • Memory efficient
  • Multi-GPU support

Orchestration

FastChat for management
  • Model routing
  • Load balancing
  • Web UI optional

Reverse Proxy

Nginx or Traefik
  • SSL termination
  • Rate limiting
  • Request routing

Monitoring

Prometheus + Grafana
  • Metrics collection
  • Alerting
  • Visualization

Performance Optimization

Model Selection

Select based on latency and throughput requirements:
Use quantization to reduce memory and improve throughput:
Quality Comparison (MMLU scores):
  • BF16: 55.8
  • Int8: 55.4 (-0.4)
  • Int4: 55.1 (-0.7)
Set appropriate max_model_len based on use case:
Longer context increases memory usage linearly.

vLLM Configuration

Multi-GPU Strategies

Split single model across GPUs:
Pros: Higher throughput per model Cons: All GPUs serve single model

Security

Authentication

SSL/TLS Configuration

Nginx SSL configuration:

Rate Limiting

Monitoring & Observability

Prometheus Metrics

Expose metrics for monitoring:

Grafana Dashboard

Key metrics to monitor:

Throughput

  • Requests per second
  • Tokens per second
  • Batch size utilization

Latency

  • p50, p95, p99 response times
  • Time to first token (TTFT)
  • Inter-token latency

Resources

  • GPU utilization
  • GPU memory usage
  • CPU and system memory

Errors

  • Error rate
  • Timeout rate
  • Queue depth

Health Checks

Implement comprehensive health checks:

Scaling Strategies

Horizontal Scaling

1

Load Balancer Setup

Configure Nginx for multiple backends:
2

Session Affinity

For stateful applications:
3

Auto-scaling

Use Kubernetes HPA or cloud auto-scaling:

Vertical Scaling

Upgrade to larger GPUs or more GPUs per node:

Disaster Recovery

Backup Strategy

Disaster Recovery Plan

1

Documentation

Maintain runbooks with:
  • System architecture diagrams
  • Deployment procedures
  • Rollback procedures
  • Contact information
2

Testing

Regularly test:
  • Failover procedures
  • Backup restoration
  • Load balancer health checks
  • Monitoring alerts
3

Automation

Automate recovery:

Cost Optimization

GPU Utilization

Higher batch sizes improve GPU utilization:
Monitor with: nvidia-smi dmon -s u
For non-critical workloads:
Implement graceful shutdown:
Match GPU to model size:

Checklist

Use this checklist before going to production:

Pre-deployment

  • Model selection and quantization decided
  • GPU resources allocated and tested
  • Load testing completed
  • Security hardening applied
  • SSL/TLS certificates configured
  • Authentication mechanism implemented
  • Rate limiting configured
  • Monitoring and alerting set up
  • Backup strategy implemented
  • Documentation updated

Deployment

  • Services deployed with systemd/Docker
  • Health checks passing
  • Load balancer configured
  • Firewall rules applied
  • Logs being collected
  • Metrics being recorded
  • Alerts being received

Post-deployment

  • Performance benchmarks validated
  • Error rates within SLA
  • Resource utilization acceptable
  • Cost within budget
  • Team trained on operations
  • Runbooks tested
  • On-call rotation established

Troubleshooting

Performance Issues

  1. Check GPU utilization: nvidia-smi
  2. Review batch size: increase --max-num-seqs
  3. Check network latency between services
  4. Review logs for bottlenecks
  5. Consider tensor parallelism

Additional Resources

vLLM Documentation

Official vLLM documentation

FastChat GitHub

FastChat source and examples

Kubernetes Guide

Deploy on Kubernetes

Performance Tuning

Advanced optimization guide