A production-oriented distributed task execution platform written in Go.
architecture:
- API service receives and validates jobs
- Jobs are persisted and enqueued
- Worker services consume and process jobs concurrently
- Retry logic and dead-letter isolation ensure reliability
- Observability is built-in (metrics, logs, health checks)
- Fully containerized for cloud deployment
The goal of this project is to model real-world backend systems used in modern cloud environments.
Client
|
v
API Service (stateless)
|
+--> PostgreSQL
|
+--> Redis (queue)
|
v
Worker Pool (N)
- Stateless API layer
- Worker pool scaling
- Queue-based decoupling
- Container-first architecture
- At-least-once delivery semantics
- Retry with exponential backoff
- Dead-letter queue isolation
- Graceful shutdown with in-flight job protection
- Prometheus metrics endpoint
- Structured JSON logging
- Job latency metrics (p95, p99)
- Queue depth monitoring
- Error rate tracking
- Health check endpoints
- Worker crash recovery
- Idempotent job processing
- Controlled retry thresholds
- Backpressure via queue buffering
- Concurrent worker execution
- Configurable worker pool size
- Retry logic with capped attempts
- Dead-letter queue handling
- Job status lifecycle tracking
- Dockerized services
- Production-ready folder structure
- Go (concurrency-focused runtime)
- Redis (message queue)
- PostgreSQL (persistent state)
- Docker and Docker Compose
- Prometheus (metrics)
- Optional: Grafana dashboard
- Client submits job
- API validates and persists job (status = queued)
- Job ID pushed to Redis queue
- Worker consumes job
- Status updated to running
- Processing occurs
- On success -> status = completed
- On failure -> retry or DLQ after max attempts
id(UUID): globally unique job identifierpayload(JSON): job input datastatus(text): current lifecycle stateattempts(int): processing attempts countercreated_at(timestamp): creation timeupdated_at(timestamp): last update time
queuedrunningcompletedfailed
cmd/
api/ # API entrypoint
worker/ # Worker entrypoint
internal/
config/ # Configuration management
db/ # PostgreSQL integration
queue/ # Redis queue abstraction
job/ # Job processing logic
observability/ # Metrics and logging
retry/ # Backoff and retry logic
deploy/
docker/ # Dockerfiles
compose/ # docker-compose.yml
scripts/
loadtest/ # k6 test scripts
docker compose -f deploy/compose/docker-compose.yml up -d --buildConfiguration defaults are in deploy/compose/.env.
Migrations run automatically via the migrate service. To re-run manually:
docker compose -f deploy/compose/docker-compose.yml run --rm migratego run ./cmd/apigo run ./cmd/workerdocker compose -f deploy/compose/docker-compose.yml up -d --scale worker=3The queue allows horizontal scaling without modifying the API layer.
curl -s -X POST http://localhost:8080/jobs \
-H "Content-Type: application/json" \
-d '{"payload":{"type":"demo","value":123}}'curl -s http://localhost:8080/jobs/<job-id>Metrics endpoint exposed at:
API: http://localhost:8080/metrics
Worker: http://localhost:9091/metrics
Example tracked metrics:
jobs_processed_totaljob_processing_duration_secondsjob_failures_totalqueue_depthworker_active_goroutines
- Redis chosen for lightweight queue abstraction
- PostgreSQL used as authoritative state store
- API remains stateless for scaling
- Workers handle retries to isolate failure domains
- Exponential backoff reduces thundering herd risk
- Structured logging for log aggregation systems
- Kubernetes-ready architecture
- Horizontal Pod Autoscaler compatible
- Health probes for liveness and readiness
- Environment-based configuration
- Graceful termination handling (SIGTERM)
- Kubernetes manifests
- Horizontal Pod Autoscaling
- Distributed tracing (OpenTelemetry)
- Circuit breaker implementation
- Multi-region queue replication
- Serverless execution comparison (cold start analysis)
This project focuses on modeling real-world cloud-native backend architecture rather than building a UI-centric application.
It demonstrates practical understanding of:
- Distributed systems patterns
- Failure isolation
- Scalable service design
- Observability-first engineering
- Production deployment thinking
MIT