Overview

Plan your infrastructure scaling strategy to handle growth while managing costs effectively.

Scaling Stages

1

Stage 1: Small Team (0-1K conversations/month)

Infrastructure:
  • Server: Render/Railway ($5-15/month)
  • Database: Supabase Free (500 MB)
  • Email: SendGrid Free (100/day)
Team Size: 1-3 agents Total Cost: $20-30/monthWhen to scale: Database >400 MB or >500 conversations/month
2

Stage 2: Growing Team (1K-5K conversations/month)

Infrastructure:
  • Server: Railway Pro or AWS t3.small ($20-30/month)
  • Database: Supabase Pro 8GB ($25/month)
  • Email: SendGrid Essentials ($20/month)
  • Redis: Upstash Free or Railway ($5-10/month)
Team Size: 3-8 agents Total Cost: $70-85/month + WhatsApp feesWhen to scale: CPU >70% consistently or database >6 GB
3

Stage 3: Medium Team (5K-20K conversations/month)

Infrastructure:
  • Server: AWS t3.medium or 2× t3.small ($50-70/month)
  • Database: AWS RDS db.t3.small ($28/month) or Supabase Team
  • Email: SendGrid Pro ($90/month) or AWS SES
  • Redis: AWS ElastiCache ($25/month)
  • Load Balancer: AWS ALB ($20/month)
Team Size: 8-20 agents Total Cost: $213+/month + WhatsApp feesWhen to scale: Multiple servers needed or >15K conversations
4

Stage 4: Large Team (20K+ conversations/month)

Infrastructure:
  • Servers: Auto-scaling group, 2-5× t3.large ($120-300/month)
  • Database: RDS Multi-AZ db.m5.large ($200/month)
  • Email: AWS SES ($0.10/1K emails)
  • Redis: ElastiCache cluster ($100/month)
  • CDN: CloudFront ($20/month)
  • Monitoring: Datadog ($100/month)
Team Size: 20-100+ agents Total Cost: $500-800/month + WhatsApp feesStill cheaper than: Zendesk at 49/agent×50=49/agent × 50 = 2,450/month

Horizontal Scaling

Run multiple application servers:
                   Load Balancer
                        |
        +---------------+----------------+
        |               |                |
   Server 1         Server 2        Server 3
        |               |                |
        +---------------+----------------+
                        |
                   Database
Benefits:
  • Handle more concurrent users
  • Zero-downtime deployments
  • Automatic failover
Cost: ~$30-60 per additional server

Database Scaling

  • Vertical Scaling
  • Read Replicas
  • Partitioning
Upgrade to larger instance:
SizeStorageRAMCPUCost/mo
Small20 GB1 GB1 vCPU$15
Medium100 GB4 GB2 vCPU$60
Large500 GB16 GB4 vCPU$200
XLarge1 TB32 GB8 vCPU$400
When: Single database can handle load

Performance Optimization

Caching Strategy

Implement Redis caching:
{
  "cache": {
    "conversations": {
      "ttl": 300, // 5 minutes
      "keys": ["user:{id}:conversations"]
    },
    "contacts": {
      "ttl": 3600, // 1 hour
      "keys": ["contact:{phone}"]
    },
    "team_status": {
      "ttl": 60, // 1 minute
      "keys": ["team:presence"]
    }
  }
}
Impact: 50-80% reduction in database queries

Database Indexing

Critical indexes for scaling:
CREATE INDEX idx_conversations_assigned_updated 
  ON conversations(assigned_to, updated_at DESC);

CREATE INDEX idx_messages_conversation_created 
  ON messages(conversation_id, created_at DESC);

CREATE INDEX idx_contacts_phone_hash 
  ON contacts USING HASH (phone);
Impact: 10-100× faster queries

Cost-Effective Scaling

Use Spot Instances

Save 60-80% on AWS EC2 with spot instances for non-critical workloads

Archive Old Data

Move conversations >6 months to cheaper storage

Optimize Images

Compress and CDN for media files

Right-Size Resources

Monitor and adjust instance sizes monthly

Monitoring for Scale

Track these metrics:
Scaling Indicators
━━━━━━━━━━━━━━━━━━━━━━━━

Server CPU: 72% (consider scaling at >75%)
Memory: 68% (consider scaling at >80%)
Database Connections: 78/100 (OK)
Response Time P95: 450ms (target <500ms)
Error Rate: 0.1% (target <1%)

Recommendation: Monitor, no action needed yet
Next review: In 7 days

Growth Planning

Plan ahead based on growth rate:
CurrentGrowthIn 3 MonthsInfrastructure
500/mo20%/mo850/moCurrent OK
2K/mo30%/mo4.4K/moUpgrade DB soon
5K/mo25%/mo9.8K/moAdd load balancer
10K/mo15%/mo15K/moScale horizontally

Next Steps