A high-performance Go backend for deployment automation that handles 1000+ requests per second with integrated Jira ticket creation and Slack notifications.
- High Performance: Handles 1000+ concurrent requests per second
- Async Processing: Background job processing with Redis queues
- Circuit Breakers: Fault tolerance for external API calls
- Rate Limiting: Intelligent rate limiting for Jira and Slack APIs
- Connection Pooling: Optimized database connection management
- Graceful Degradation: Continues operation even when external services fail
- Comprehensive Monitoring: Prometheus metrics and health checks
- Horizontal Scaling: Stateless design for easy horizontal scaling
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Frontend ββββββ Go API ββββββ PostgreSQL β
β (React) β β Server β β Database β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
ββββββββββββββ¬ββββββββββββββ
β β β
ββββββββββββ βββββββββββββββ ββββββββββββ
β Redis β β Slack β β Jira β
β Queue β β API β β API β
ββββββββββββ βββββββββββββββ ββββββββββββ
- Go 1.21+
- PostgreSQL 14+
- Redis 6+
- Docker & Docker Compose (optional)
- Clone the repository
git clone <repository-url>
cd go-backend- Install dependencies
go mod download- Set up environment variables
cp .env.example .env
# Edit .env with your configuration- Run database migrations
make migrate-up- Start the application
make run- Using Docker Compose
docker-compose up -d- Build and run manually
docker build -t dep-tracker-backend .
docker run -p 8080:8080 dep-tracker-backend| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 8080 |
No |
DATABASE_URL |
PostgreSQL connection string | - | Yes |
REDIS_URL |
Redis connection string | redis://localhost:6379 |
Yes |
SLACK_BOT_TOKEN |
Slack Bot User OAuth Token | - | Yes |
SLACK_CHANNEL_ID |
Default Slack channel ID | - | Yes |
JIRA_BASE_URL |
Jira instance URL | - | Yes |
JIRA_EMAIL |
Jira user email | - | Yes |
JIRA_API_TOKEN |
Jira API token | - | Yes |
JIRA_PROJECT_KEY |
Default Jira project key | - | Yes |
GIN_MODE |
Gin framework mode | debug |
No |
LOG_LEVEL |
Log level (debug, info, warn, error) | info |
No |
# Database Connection Pool
DB_MAX_OPEN_CONNS=100
DB_MAX_IDLE_CONNS=10
DB_CONN_MAX_LIFETIME=1h
# Redis Configuration
REDIS_POOL_SIZE=100
REDIS_MIN_IDLE_CONNS=10
# Rate Limiting
JIRA_RATE_LIMIT=60 # requests per minute
SLACK_RATE_LIMIT=120 # requests per minute
# Circuit Breaker
CIRCUIT_BREAKER_MAX_REQUESTS=100
CIRCUIT_BREAKER_INTERVAL=60s
CIRCUIT_BREAKER_TIMEOUT=10sGET /api/deployments- List deploymentsPOST /api/deployments- Create deploymentGET /api/deployments/:id- Get deployment by IDPUT /api/deployments/:id- Update deploymentPUT /api/deployments/:id/approval- Update deployment approval
GET /api/jira-tickets- List Jira ticketsPOST /api/jira-tickets- Create Jira ticketGET /api/jira-tickets/:key- Get ticket by key
GET /api/slack-messages- List Slack messagesPOST /api/slack/webhook- Slack webhook endpoint
GET /api/templates- List message templatesPOST /api/templates- Create templatePUT /api/templates/:id- Update templateDELETE /api/templates/:id- Delete template
GET /api/configurations- List configurationsPUT /api/configurations/:key- Update configuration
GET /api/channel-mappings- List channel mappingsPOST /api/channel-mappings- Create mappingDELETE /api/channel-mappings/:id- Delete mapping
GET /health- Health checkGET /metrics- Prometheus metricsGET /api/stats- Application statistics
The application provides comprehensive health checks:
- Database connectivity
- Redis connectivity
- External API status (Jira, Slack)
Prometheus metrics are exposed at /metrics:
- Request duration and count
- Database connection pool stats
- Queue processing metrics
- External API call metrics
- Circuit breaker stats
Structured JSON logging with configurable levels:
{
"timestamp": "2024-01-01T12:00:00Z",
"level": "info",
"message": "Deployment created",
"deployment_id": "123",
"project": "user-service",
"environment": "production"
}- Jira Ticket Creation: Async processing with retry logic
- Slack Notifications: Batched message sending
- SLA Metric Calculation: Periodic metric updates
- Data Cleanup: Scheduled cleanup of old records
# Redis Queue Settings
queues:
jira:
workers: 5
retry_attempts: 3
retry_delay: 30s
slack:
workers: 3
retry_attempts: 5
retry_delay: 10s
metrics:
workers: 2
schedule: "*/5 * * * *" # Every 5 minutes- Per-IP rate limiting: 1000 requests/minute
- Per-endpoint rate limiting: Configurable per route
- Burst protection with token bucket algorithm
- Request payload validation using Go validator
- SQL injection prevention with parameterized queries
- XSS protection with input sanitization
- Slack webhook signature verification
- Jira API token validation
- Optional JWT authentication for API endpoints
Concurrent Users: 1000
Duration: 5 minutes
Average Response Time: 15ms
95th Percentile: 45ms
99th Percentile: 120ms
Throughput: 1,200 requests/second
Error Rate: 0.1%
- Memory: ~100MB at 1000 RPS
- CPU: ~20% on 4-core system
- Database Connections: ~50 active connections
- Redis Memory: ~50MB for queue data
- Using Docker Compose
# Production docker-compose
docker-compose -f docker-compose.prod.yml up -d- Kubernetes Deployment
kubectl apply -f k8s/- Environment-specific Configuration
# Staging
make deploy-staging
# Production
make deploy-productionHorizontal Scaling:
- Each instance is stateless
- Use load balancer for traffic distribution
- Scale based on CPU/memory metrics
Database Scaling:
- Read replicas for read-heavy workloads
- Connection pooling optimization
- Query optimization and indexing
Redis Scaling:
- Redis Cluster for high availability
- Separate queues for different job types
- Monitor queue length and processing time
High Memory Usage
# Check goroutine leaks
curl http://localhost:8080/debug/pprof/goroutine
# Monitor garbage collection
GODEBUG=gctrace=1 ./dep-tracker-backendDatabase Connection Issues
# Check connection pool stats
curl http://localhost:8080/metrics | grep db_connections
# Validate database connectivity
make db-pingQueue Processing Delays
# Monitor queue lengths
redis-cli llen jira_queue
redis-cli llen slack_queue
# Check worker status
curl http://localhost:8080/health# Enable debug logging
export LOG_LEVEL=debug
export GIN_MODE=debug
# Enable pprof endpoint
export ENABLE_PPROF=true- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Go best practices and idioms
- Write comprehensive tests (aim for >80% coverage)
- Use structured logging
- Document API changes
- Performance test critical paths
This project is licensed under the MIT License - see the LICENSE file for details.
--------------------- WIP ----------------------------
- Documentation: Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ for high-performance deployment automation