Cost Analysis & Financial Projections Analysis Date: January 13, 2025
Planning Horizon: 12 months Target Scale: 50,000 concurrent users Currency: USD --- ## Current Monthly Costs (Baseline) ### Infrastructure Breakdown | Service | Tier/Plan | Specifications | Monthly Cost | Annual Cost | |---------|-----------|----------------|--------------|-------------| | Railway (Application) | Hobby | 2 vCPU, 4GB RAM, 1 instance | $5.00 | $60.00 | | Railway (Redis) | Included | 256MB, shared instance | $0.00 | $0.00 | | Supabase (Database) | Free | 500MB storage, 100 connections | $0.00 | $0.00 | | Optic Odds API | Free | 6,000 req/min limit | $0.00 | $0.00 | | Cloudflare | Not yet deployed | - | $0.00 | $0.00 | | Monitoring | None | - | $0.00 | $0.00 | | Domain/DNS | Existing | - | $0.00 | $0.00 | | TOTAL | | | $5.00/mo | $60.00/yr | Per User Cost (50 current users): $0.10/month --- ## Projected Costs by User Scale ### Scenario 1: 1,000 Concurrent Users Infrastructure Requirements:
- Application Servers: 2 Railway instances (redundancy + load distribution)
- Redis: Upgrade to 1GB dedicated instance
- Database: Supabase Pro (better performance, connection pooling)
- PgBouncer: Self-hosted on Railway (lightweight)
- API Usage: ~30,000 API calls/day with caching | Service | Tier/Plan | Monthly Cost | Notes | |---------|-----------|--------------|-------| | Railway (App) | 2x Pro instances | $40 | 4GB RAM ea ch, autoscaling | | Railway (Redis) | 1GB instance | $15 | Dedicated, connection pooling | | Railway (PgBouncer) | Small instance | $5 | 1GB RAM, transaction pooling | | Supabase | Pro | $25 | Better performance, 7-day backups | | Optic Odds API | Free tier | $0 | Still within 6k/min limit with caching | | Cloudflare | Free | $0 | CDN for static assets | | SUBTOTAL | | $85/mo | | | Contingency (20%) | | $17/mo | For traffic spikes | | TOTAL | | $102/mo | $1,224/yr | Per User Cost: $0.102/month ($1.22/year) Key Assumptions:
- 70% cache hit rate reduces API calls by 60%
- Peak traffic = 3x average (requires scaling buffer)
- No monitoring tools yet (using built-in dashboards) --- ### Scenario 2: 10,000 Concurrent Users Infrastructure Requirements:
- Application Servers: 5 Railway instances (load balanced)
- Redis: Redis Cloud 2GB cluster (3 nodes for HA)
- Database: Supabase Pro + PgBouncer (200 effective connections)
- Background Workers: 2 Celery worker instances
- API Usage: ~120,000 API calls/day with aggressive caching | Service | Tier/Plan | Monthly Cost | Notes | |---------|-----------|--------------|-------| | Railway (App) | 5x Pro instances | $100 | Autoscaling, multi-region option | | Railway (Workers) | 2x Worker instances | $30 | Celery background jobs | | Railway (PgBouncer) | 2x instances (HA) | $20 | Failover support | | Redis Cloud | 2GB Standard | $50 | 3-node cluster, pub/sub | | Supabase | Pro + extras | $50 | Higher IOPS, daily backups | | Optic Odds API | Paid tier estimate | $50 | ~150k req/day, bulk pricing | | Cloudflare | Free | $0 | Free tier still sufficient | | Monitoring | Basic (optional) | $25 | Uptime Robot + log aggregation | | SUBTOTAL | | $325/mo | | | Contingency (15%) | | $49/mo | Smaller buffer needed | | TOTAL | | $374/mo | $4,488/yr | Per User Cost: $0.037/month ($0.45/year) Key Optimizations:
- 85% cache hit rate reduces API calls by 75%
- CDN offloads 60% of static requests
- PgBouncer enables 1,000+ effective DB connections
- Background workers reduce real-time API overhead --- ### Scenario 3: 50,000 Concurrent Users (Target) Infrastructure Requirements:
- Application Servers: 12-15 Railway instances (horizontally scaled)
- Redis: Redis Cloud 5GB Premium cluster (6 nodes: 3 master + 3 replica)
- Database: Supabase Team tier (read replicas, point-in-time recovery)
- Background Workers: 8 Celery instances (priority queues)
- API Usage: ~400,000 API calls/day (90% cache hit rate)
- WebSocket: Dedicated WebSocket service cluster (5 instances) | Service | Tier/Plan | Monthly Cost | Notes | |---------|-----------|--------------|-------| | Railway (App) | 12x Pro instances | $240 | Multi-region, autoscaling 8-15 instances | | Railway (WebSocket) | 5x instances | $75 | Dedicated WebSocket cluster | | Railway (Workers) | 8x Worker instances | $120 | Celery with priority queues | | Railway (PgBouncer) | 3x instances (HA) | $30 | Load balanced connection pooling | | Redis Cloud | 5GB Premium | $180 | 6-node cluster, multi-AZ, pub/sub | | Supabase | Team | $599 | 3x read replicas, 99.9% SLA, support | | Optic Odds API | Enterprise | $300 | ~400k req/day, dedicated support | | Cloudflare | Pro | $20 | Advanced DDoS, image optimization | | Datadog APM (optional) | Pro | $150 | Full observability, alerting | | SUBTOTAL | | $1,714/mo | | | Contingency (10%) | | $171/mo | Well-architected, less buffer needed | | TOTAL (without APM) | | $1,364/mo | $16,368/yr | | TOTAL (with APM) | | $1,885/mo | $22,620/yr | Per User Cost: $0.027-0.038/month ($0.33-0.45/year) Enterprise Features Included:
- 99.9% uptime SLA
- Multi-region deployment
- Automatic failover
- Real-time monitoring & alerting
- 24/7 support (Supabase Team)
- Horizontal autoscaling
- Point-in-time recovery (PITR)
- Advanced caching & CDN Cost Efficiency Improvements:
- 95% cache hit rate = 20x reduction in API calls
- CDN offloads 80% of GET requests
- Read replicas reduce primary DB load by 70%
- WebSocket clustering handles 50k connections
- Background workers process jobs asynchronously --- ## Cost Scaling Curve ### Infrastructure Cost Growth vs User Growth | Users | Monthly Cost | Per User | YoY Growth | Notes | |-------|--------------|----------|------------|-------| | 50 | $5 | $0.100 | - | Current baseline | | 100 | $10 | $0.100 | 100% | Hobby tier sufficient | | 500 | $45 | $0.090 | 350% | First upgrade needed | | 1,000 | $102 | $0.102 | 126% | Pro tier, redundancy | | 5,000 | $250 | $0.050 | 145% | Economies of scale begin | | 10,000 | $374 | $0.037 | 49% | Cluster setup, caching optimized | | 25,000 | $850 | $0.034 | 127% | Multi-region deployment | | 50,000 | $1,364 | $0.027 | 60% | Full enterprise stack (no APM) | | 50,000 + APM | $1,885 | $0.038 | 39% | With monitoring | Key Insights:
- Economies of Scale: Cost per user drops 73% from 100 to 50,000 users
- Growth Stages: Three major cost jumps: - 500 users: First infrastructure upgrade (+350%) - 1,000 users: Redundancy required (+126%) - 10,000 users: Enterprise tooling (+145%)
- Linear After 10k: Beyond 10,000 users, costs scale near-linearly
- Monitoring Optional: Can save $150/mo by using free tools early on --- ## Revenue Requirements & Break-Even Analysis ### Assumptions
- Average Revenue Per User (ARPU): $5/month (conservative) - Mix of rake from bets, premium features, or subscriptions - Industry standard for sports betting platforms: $5-20/month
- Operating Margin Target: 70% (industry standard for SaaS)
- Customer Acquisition Cost (CAC): Not included (separate budget) ### Break-Even Analysis | User Count | Infrastructure Cost | Revenue @ $5/user | Profit | Margin | |------------|---------------------|-------------------|--------|--------| | 50 | $5 | $250 | $245 | 98.0% | | 100 | $10 | $500 | $490 | 98.0% | | 500 | $45 | $2,500 | $2,455 | 98.2% | | 1,000 | $102 | $5,000 | $4,898 | 98.0% | | 5,000 | $250 | $25,000 | $24,750 | 99.0% | | 10,000 | $374 | $50,000 | $49,626 | 99.3% | | 25,000 | $850 | $125,000 | $124,150 | 99.3% | | 50,000 | $1,364 | $250,000 | $248,636 | 99.5% | Critical Finding: Infrastructure is NOT a cost bottleneck. Even at 50k users:
- Infrastructure = 0.5% of revenue
- 99.5% margin on infrastructure
- Focus should be on user acquisition, not cost optimization Minimum ARPU for Profitability: | User Count | Infrastructure Cost | Min ARPU (Break-Even) | Current ARPU | Margin of Safety | |------------|---------------------|-----------------------|--------------|------------------| | 1,000 | $102/mo | $0.102/mo | $5.00/mo | 49x | | 10,000 | $374/mo | $0.037/mo | $5.00/mo | 135x | | 50,000 | $1,364/mo | $0.027/mo | $5.00/mo | 185x | Even at $1/user/month ARPU:
- 1,000 users: $1,000 revenue - $102 cost = $898 profit (89.8% margin)
- 10,000 users: $10,000 revenue - $374 cost = $9,626 profit (96.3% margin)
- 50,000 users: $50,000 revenue - $1,364 cost = $48,636 profit (97.3% margin) Conclusion: Infrastructure costs are negligible compared to potential revenue. Scaling is economically viable. --- ## Cost Optimization Strategies ### Strategy 1: Aggressive Caching (High Impact) Current State:
- Cache hit rate: 62%
- API calls: 12,792/day
- Estimated cost: $0 (free tier) Optimized State:
- Cache hit rate: 95% (+53%)
- API calls: 2,500/day (-80%)
- Estimated savings at 50k users: $240/month Implementation:
- Tiered caching (live 30s, upcoming 5min, scheduled 30min)
- Materialized views for aggregations
- Prefetching popular games
- CDN for static assets ROI: $240/month savings ÷ 40 engineering hours = $6/hour saved (ongoing) --- ### Strategy 2: Request Batching (Medium Impact) Current State:
- Individual API requests per game
- Network overhead: ~100ms per request
- 12,792 requests/day Optimized State:
- Batch 20-50 games per request
- Network overhead: ~100ms per batch
- 640 requests/day (-95%)
- Estimated savings at 50k users: $180/month Implementation:
- Batch endpoint:
POST /fixtures/batchwith array of game IDs - Client-side request coalescing (merge within 500ms window)
- Server-side request deduplication ROI: $180/month savings ÷ 20 engineering hours = $9/hour saved --- ### Strategy 3: Database Read Replicas (Medium Impact) Current State:
- Single primary database
- All reads + writes on same instance
- No separation of concerns Optimized State:
- 1 primary (writes only) + 2 read replicas (reads)
- 70% load reduction on primary
- Can downgrade primary tier
- Estimated savings: $100/month (avoid Team tier at smaller scale) Implementation:
- Configure Supabase read replicas (if on Pro+ tier)
- Route odds queries to replicas
- Keep writes on primary ROI: $100/month savings ÷ 8 engineering hours = $12.50/hour saved --- ### Strategy 4: CDN for Static Assets (High Impact) Current State:
- All requests hit FastAPI server
- Server CPU wasted on static files
- No edge caching Optimized State:
- Cloudflare CDN with edge caching
- 80% of GET requests served from CDN
- Server instances reduced by 30%
- Estimated savings at 50k users: $120/month Implementation:
- Cloudflare in front of Railway
- Cache headers on GET endpoints
- Edge caching rules (1 hour for /sports, /leagues) ROI: $120/month savings ÷ 12 engineering hours = $10/hour saved --- ### Strategy 5: Predictive Pre-Caching (Advanced, High Impact) Current State:
- Reactive caching only (cache on miss)
- Users wait for first load
- Poor UX for popular games Optimized State:
- Pre-cache popular games before users request
- 98% cache hit rate for top 20% of games
- Reduced API calls by additional 10%
- Estimated savings at 50k users: $60/month
- More importantly: Improved UX = higher retention Implementation:
- Track game popularity (views, bets)
- Background job prefetches top 20% of games
- Refresh based on popularity tier ROI: $60/month savings + UX improvement ÷ 30 engineering hours = $2/hour + retention --- ### Combined Optimization Impact | Strategy | Monthly Savings (50k) | Eng Hours | Priority | |----------|----------------------|-----------|----------| | Aggressive Caching | $240 | 40 | HIGH | | Request Batching | $180 | 20 | HIGH | | CDN for Static Assets | $120 | 12 | HIGH | | Read Replicas | $100 | 8 | MEDIUM | | Predictive Caching | $60 | 30 | MEDIUM | | TOTAL | $700/mo | 110 hrs | - | Optimized 50k User Cost:
- Baseline: $1,364/month
- After optimizations: $664/month (-51%)
- Per user: $0.013/month ROI Calculation:
- One-time engineering cost: 110 hours × $100/hr = $11,000
- Monthly savings: $700
- Payback period: 16 months
- 3-year NPV: $700 × 36 - $11,000 = $14,200 saved --- ## Cost Comparison: Alternatives ### Alternative 1: Serverless Architecture (AWS Lambda/Vercel) | Service | Monthly Cost (50k users) | |---------|--------------------------| | AWS Lambda (compute) | $350 | | AWS API Gateway | $180 | | ElastiCache (Redis) | $200 | | RDS PostgreSQL | $450 | | S3 + CloudFront | $50 | | TOTAL | $1,230/mo | Pros: Auto-scaling, pay-per-use Cons: Cold starts, vendor lock-in, complex debugging Verdict: Similar cost, more complexity --- ### Alternative 2: Self-Hosted (DigitalOcean/Linode) | Service | Monthly Cost (50k users) | |---------|--------------------------| | Droplets (12x 4GB) | $576 | | Managed Redis | $80 | | Managed PostgreSQL | $240 | | Load Balancer | $30 | | Backups | $50 | | CDN (Bunny) | $10 | | TOTAL | $986/mo | Pros: Lower cost ($378/mo savings) Cons: More DevOps overhead, manual scaling, no managed services Verdict: Cheaper but requires dedicated DevOps engineer ($8k+/mo) --- ### Alternative 3: Keep Current (Railway + Supabase) | Service | Monthly Cost (50k users) | |---------|--------------------------| | Railway (all services) | $465 | | Redis Cloud | $180 | | Supabase Team | $599 | | Optic Odds API | $300 | | Cloudflare | $20 | | TOTAL | $1,564/mo | Pros: Simplest, least DevOps overhead, excellent DX Cons: $200/mo more expensive than AWS Verdict: Recommended - Developer productivity > $200/mo savings --- ## Risk Assessment & Cost Contingencies ### High-Risk Cost Items 1. Optic Odds API Overage
- Risk: Exceed free tier, sudden jump to paid plan
- Likelihood: Medium (without caching improvements)
- Impact: +$300-500/month
- Mitigation: Implement aggressive caching in Phase 1
- Contingency: $500/month buffer for API costs 2. Database Storage Growth
- Risk: Storage costs grow faster than expected
- Likelihood: Medium (odds history accumulation)
- Impact: +$50-100/month for additional storage
- Mitigation: Archive old odds_history data (>6 months)
- Contingency: Automated cleanup job 3. Traffic Spikes (Event-Driven)
- Risk: Major sporting event causes 10x traffic spike
- Likelihood: High (Super Bowl, March Madness, etc.)
- Impact: +$200-400/month during event
- Mitigation: Autoscaling + CDN + aggressive rate limiting
- Contingency: Reserve $400/month for peak events 4. DDoS Attack
- Risk: Malicious traffic causes infrastructure overload
- Likelihood: Low (not high-profile yet)
- Impact: +$500-1,000 one-time cost
- Mitigation: Cloudflare DDoS protection (included in Pro)
- Contingency: Cloudflare Pro tier ($20/mo) prevents this ### Medium-Risk Cost Items 5. Database Connection Exhaustion
- Risk: Hit Supabase connection limits, forced to upgrade
- Likelihood: Medium (without PgBouncer)
- Impact: +$250/month (premature Team upgrade)
- Mitigation: Deploy PgBouncer in Phase 1
- Contingency: Already in roadmap 6. Redis Memory Pressure
- Risk: Run out of Redis memory, need larger instance
- Likelihood: Medium (without cache eviction strategy)
- Impact: +$50-100/month
- Mitigation: Tiered caching + aggressive TTL
- Contingency: Upgrade path is straightforward ### Total Risk Contingency Budget | Risk Item | Likelihood | Monthly Impact | Annualized | |-----------|------------|----------------|------------| | API Overage | Medium | $500 | $6,000 | | Storage Growth | Medium | $100 | $1,200 | | Traffic Spikes | High | $400 (peak) | $1,200 (3 events) | | DDoS Attack | Low | $20 (prevention) | $240 | | DB Exhaustion | Medium | $0 (mitigated) | $0 | | Redis Memory | Medium | $100 | $1,200 | | TOTAL RISK | | $1,120 | $9,840 | Recommended Contingency Reserve: $1,200/month ($14,400/year) Total 50k User Budget:
- Base cost: $1,364/month
- Contingency: $1,200/month
- Grand Total: $2,564/month ($30,768/year)
- Still only 1.0% of revenue at $5 ARPU --- ## Recommendations ### Immediate (Phase 1)
- Deploy PgBouncer - Prevents costly database upgrade
- Implement tiered caching - Reduces API costs by 60%
- Add Cloudflare CDN - Offloads 80% of traffic (free tier OK for now) ### Short-Term (Phase 2)
- Add basic monitoring - Prevent surprise overages
- Implement request batching - Further reduce API costs
- Set up automated alerts - Catch issues before they cost money ### Long-Term (Phase 3+)
- Migrate to Supabase Team (only when needed at ~25k users)
- Consider Datadog APM (optional, nice-to-have)
- Evaluate self-hosted alternative (if cost becomes issue at 100k+ users) ### Not Recommended
- Optimizing for cost before 10k users (premature)
- Self-hosting to save $200/month (DevOps time costs more)
- Over-engineering caching to hit 99% hit rate (diminishing returns) --- ## Budget Timeline (12 Months) | Month | Projected Users | Monthly Cost | Cumulative Cost | Notes | |-------|----------------|--------------|-----------------|-------| | Jan | 145 | $5 | $5 | Current state | | Feb | 250 | $10 | $15 | Phase 1 complete | | Mar | 400 | $25 | $40 | | | Apr | 600 | $45 | $85 | First upgrade (2 instances) | | May | 850 | $65 | $150 | | | Jun | 1,200 | $102 | $252 | Supabase Pro upgrade | | Jul | 1,800 | $150 | $402 | | | Aug | 2,800 | $200 | $602 | Phase 2 complete | | Sep | 4,500 | $280 | $882 | | | Oct | 7,000 | $350 | $1,232 | | | Nov | 10,500 | $450 | $1,682 | | | Dec | 15,000 | $650 | $2,332 | End of Year 1 | Year 1 Total Infrastructure Cost: $2,332 Year 1 Total Revenue (avg 7,900 users × $5): $473,400 Year 1 Infrastructure as % of Revenue: 0.49% --- ## Executive Summary ### Key Findings 1. Infrastructure is NOT a bottleneck - At 50k users: $1,364/mo = 0.5% of revenue - 185x margin of safety vs minimum viable ARPU 2. Costs scale sub-linearly - Per-user cost drops 73% from 100 to 50,000 users - Economies of scale kick in at ~5,000 users 3. Focus on growth, not cost optimization - $1,364/mo at 50k users is negligible - CAC and user retention matter 1000x more - Engineering time better spent on features 4. Current architecture scales well - Railway + Supabase is cost-effective - Self-hosting saves $378/mo but costs $8k+/mo in DevOps time - Managed services = better ROI 5. Risk is manageable - Total risk contingency: $1,200/mo - Still only 1% of revenue with all risks realized - Most risks mitigable with Phase 1 improvements ### Recommended Action ** PROCEED with Phase 1 implementation**
- Total 4-week cost: $20-40 in infrastructure
- Engineering cost: 80 hours (~$8,000 if outsourced)
- Monthly savings at scale: $700/mo
- Payback period: 12-16 months
- Enables scaling to 50k users without limits Infrastructure costs are a non-issue. Focus on building features that drive user growth. --- Analysis Prepared By: Engineering & Finance Team Last Updated: January 13, 2025 Next Review: Quarterly or at 5k user milestone