Skip to content

Instantly share code, notes, and snippets.

@hungdoansy
Created September 12, 2025 04:43
Show Gist options
  • Select an option

  • Save hungdoansy/1410dfaec80c084d22633ac16ba7092d to your computer and use it in GitHub Desktop.

Select an option

Save hungdoansy/1410dfaec80c084d22633ac16ba7092d to your computer and use it in GitHub Desktop.

Tash - Slack PR Thread Bot - Cost Analysis

Overview

This document provides detailed cost analysis and resource estimates for the Tash Slack PR Thread Bot based on the following usage patterns:

  • 10 Slack users in 1 workspace
  • 6 GitHub repositories being tracked
  • 20 pull requests per day across all repos
  • 2-3 approvals per PR (40-60 approval events/day)
  • 5-10 comments per PR (100-200 comment events/day)
  • 20 merges per day
  • 4 active Slack channels
  • 100+ Slack messages per day from the bot

Daily Activity Breakdown

Metric Daily Volume Monthly Volume
Pull Requests 20 600
Webhook Events 160-280 4,800-8,400
Slack Messages 160-280 4,800-8,400
Database Records 260-380 7,800-11,400
Bandwidth 4.8-5.5 MB 145-165 MB

Resource Requirements

1. Database Storage (PostgreSQL)

Daily Data Growth:

  • PR Tracking Records: 20 PRs × 4 channels = 80 records/day
  • Message Deliveries: 160-280 delivery records/day
  • User Connections: Minimal (10 users, mostly static)
  • Health Checks: ~1,440 records/day (every minute)

Storage per Record:

  • PR Tracking: ~500 bytes
  • Message Delivery: ~400 bytes
  • User Connection: ~1KB
  • Health Check: ~200 bytes

Storage Calculations:

  • Monthly Storage: ~12.2 MB
  • Annual Storage: ~150 MB
  • 10-Year Projection: ~1.5 GB

Recommendation: AWS RDS PostgreSQL (db.t3.micro) with 20GB storage

2. Memory Usage

Redis Memory Requirements:

  • Queue Jobs: ~320-560 KB/day
  • Cached PR Tracking: ~80 KB
  • User Mappings: ~20 KB
  • Rate Limiting Data: ~4 KB
  • Delivery Locks: ~1 KB
  • Total Redis Memory: ~425-665 KB

Application Memory:

  • Node.js Base: ~50-100 MB
  • Dependencies: ~30-50 MB
  • Queue Processing: ~20-30 MB
  • Total Application Memory: ~100-180 MB

Recommendation: AWS ElastiCache Redis (cache.t3.micro) with 0.5GB memory

3. Bandwidth Usage

Incoming Traffic (GitHub Webhooks):

  • Webhook Payloads: 160-280 events × 5KB = ~800KB-1.4MB/day
  • Monthly Incoming: ~25-45 MB

Outgoing Traffic (Slack API + Database):

  • Slack Messages: 160-280 messages × 2KB = ~320KB-560KB/day
  • Database Queries: ~1,000 queries/day × 1KB = ~1MB/day
  • Redis Operations: ~5,000 operations/day × 0.5KB = ~2.5MB/day
  • Monthly Outgoing: ~115-125 MB

Total Bandwidth: ~140-170 MB/month

AWS Infrastructure Recommendations

Option 1: High Availability Setup

Service Instance Type Monthly Cost
Application Server
EC2 t3.micro (1 vCPU, 1GB RAM) On-Demand $8.47
Application Load Balancer Standard $16.20
Auto Scaling Group Min: 1, Max: 2 $0
Database
RDS PostgreSQL db.t3.micro Multi-AZ $24.82
Storage (20GB) gp2 $2.30
Cache
ElastiCache Redis cache.t3.micro 0.5GB $12.41
Networking
VPC Standard $0
NAT Gateway Standard $32.40
Data Transfer ~150MB/month $0.50
Monitoring
CloudWatch Basic $5.00
CloudTrail Basic $2.00
Total $102.10

Option 2: Cost-Effective Setup

Service Instance Type Monthly Cost
Application Server
ECS Fargate (0.25 vCPU, 0.5GB) On-Demand $6.00
Application Load Balancer Standard $16.20
Database
RDS PostgreSQL db.t3.micro Single-AZ $12.41
Storage (20GB) gp2 $2.30
Cache
ElastiCache Redis cache.t3.micro 0.5GB $12.41
Networking
VPC Standard $0
NAT Gateway Standard $32.40
Data Transfer ~150MB/month $0.50
Monitoring
CloudWatch Basic $5.00
CloudTrail Basic $2.00
Total $87.22

Option 3: Minimal Setup (Development/Testing)

Service Instance Type Monthly Cost
Application Server
EC2 t3.micro On-Demand $8.47
Database
RDS PostgreSQL db.t3.micro Single-AZ $12.41
Storage (20GB) gp2 $2.30
Cache
ElastiCache Redis cache.t3.micro 0.5GB $12.41
Networking
VPC Standard $0
Monitoring
CloudWatch Basic $5.00
Total $40.59

Performance Analysis

Latency Breakdown

  • Webhook Reception: ~10-20ms
  • Queue Processing: ~5-10ms
  • Database Operations: ~20-50ms
  • Slack API Call: ~100-200ms
  • Total Expected Latency: ~135-280ms

Performance Target Met: Well under the 500ms requirement

Scalability

  • Current Load: 20 PRs/day, 160-280 webhook events/day
  • 10x Growth Capacity: 200 PRs/day, 1,600-2,800 webhook events/day
  • Infrastructure Changes Required: None (current setup can handle 10x growth)

Cost Optimization Recommendations

Immediate Optimizations

  1. Start with Minimal Setup: Use Option 3 for initial deployment
  2. Monitor Usage: Track actual vs. projected usage for 1-2 months
  3. Upgrade as Needed: Move to Option 2 if high availability is required

Long-term Optimizations

  1. Reserved Instances: Save 30-50% with 1-year commitments
  2. Spot Instances: Use for non-critical workloads (development)
  3. Auto Scaling: Scale down during low-usage periods
  4. Data Archiving: Archive old delivery logs to S3 (cheaper storage)

Reserved Instance Pricing (1-Year)

  • EC2 t3.micro: $6.10/month (28% savings)
  • RDS db.t3.micro: $8.90/month (28% savings)
  • ElastiCache cache.t3.micro: $8.90/month (28% savings)

Budget Recommendations

Phase 1: Development & Testing (Months 1-2)

  • Budget: $50/month
  • Setup: Option 3 (Minimal)
  • Purpose: Validate functionality and measure actual usage

Phase 2: Production (Months 3+)

  • Budget: $100/month
  • Setup: Option 2 (Cost-Effective)
  • Purpose: Reliable production deployment

Phase 3: Scale (If Growth Occurs)

  • Budget: $150/month
  • Setup: Option 1 (High Availability)
  • Purpose: Handle increased load and ensure 99.9%+ uptime

Monitoring & Alerting

Key Metrics to Monitor

  • Webhook Processing Time: Should stay under 500ms
  • Queue Depth: Alert if > 100 pending jobs
  • Database Connections: Alert if > 80% of max connections
  • Memory Usage: Alert if > 80% of allocated memory
  • Error Rate: Alert if > 5% of webhook processing fails

Cost Monitoring

  • Daily Cost Tracking: Set up AWS Cost Explorer
  • Budget Alerts: Set $50, $100, $150 thresholds
  • Resource Utilization: Monitor actual vs. projected usage

Conclusion

The Tash Slack PR Thread Bot has very modest resource requirements due to its efficient architecture and relatively low usage volume. The application can be deployed cost-effectively while meeting all performance and reliability requirements.

Recommended Starting Point: Option 3 (Minimal Setup) at $41/month, with the ability to scale up to Option 2 ($87/month) or Option 1 (~$102/month) as needed.

Key Benefits:

  • ✅ Meets 500ms latency requirement
  • ✅ Supports high availability when needed
  • ✅ Scales to 10x current load without changes
  • ✅ Cost-effective for the provided value
  • ✅ Future-proof architecture

Last Updated: $(date) Analysis Based On: 10 users, 20 PRs/day, 4 channels, 6 repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment