Skip to content
bhusareMayurPublic

About

Production-inspired distributed background job processing engine built with Go, Redis, and PostgreSQL. Features worker pools, retries, DLQ, crash recovery, scheduling, observability, idempotency, and backpressure handling.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


A fault-tolerant, distributed job processing engine built in Go. Built for teams who can't afford to lose a single job.


Go PostgreSQL Redis Prometheus Grafana Docker


License PRs Welcome Version


πŸ€” Why GoQueue?

Processing everything inside a synchronous HTTP request is fragile:

❌ Timeouts kill long-running work
❌ Retries duplicate side effects
❌ A single crash silently swallows jobs

GoQueue solves this by decoupling job creation from job execution:

βœ… Persists every job to PostgreSQL the moment it's created
βœ… Pushes to Redis for fast async dispatch
βœ… Executes through concurrent Go workers
βœ… Full crash recovery, priority scheduling, and tracing built in

✨ Core Features

Feature Description
πŸ—„οΈ Dual-layer persistence PostgreSQL for durability Β· Redis for throughput
πŸ‘· Concurrent worker pools Scalable goroutine-based workers process jobs in parallel
πŸ”„ Smart retry + backoff Non-blocking delayed queues with exponential backoff
☠️ Dead Letter Queue Permanently failed jobs routed for inspection and replay
πŸ’€ Crash recovery Visibility timeouts + Reaper service recover stuck jobs
🎯 Priority dispatching High · Medium · Low priority queues
πŸ”‘ Idempotency keys Safe job creation - no accidental duplicates
πŸ” Correlation IDs Every job traceable end-to-end via structured JSON logs
πŸ›‘ Backpressure shedding Returns HTTP 429 when queue capacity is exceeded
πŸ“Š Full observability Prometheus metrics + Grafana dashboards out of the box
🧹 Graceful shutdown Workers drain in-flight jobs safely on termination signals


πŸ—οΈ Architecture

GoQueue Distributed Job Processing Architecture

End-to-end architecture of GoQueue showing job creation, reliable delivery, distributed workers, retry orchestration, crash recovery, and observability.


πŸš€ Quick Start

The fastest way to run GoQueue is via Docker Compose - spins up the API, workers, PostgreSQL, Redis, Prometheus, and Grafana in one command.

Prerequisites

  • 🐳 Docker & Docker Compose
  • make (optional but recommended)

1. Clone the repository

git clone https://github.com/bhusaremayur/goqueue.git
cd goqueue

2. Start all services

# With Docker Compose
docker-compose -f deployments/docker-compose.yml up -d

# Or with Make
make up

3. Verify services are running

docker-compose ps
Service URL Description
🟒 Go API Server http://localhost:8080 Job submission & status
πŸ“Š Grafana Dashboard http://localhost:3000 Pre-built dashboards
πŸ“ˆ Prometheus http://localhost:9090 Raw metrics

πŸ“ Repository Structure

goqueue/
β”‚
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ api/                β†’  API server entry point
β”‚   β”œβ”€β”€ worker/             β†’  Worker process entry point
β”‚   └── example-app/        β†’  Example usage
β”‚
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ job/                β†’  Core job domain logic
β”‚   β”œβ”€β”€ storage/
β”‚   β”‚   β”œβ”€β”€ postgres/       β†’  PostgreSQL repositories
β”‚   β”‚   β”‚   └── migrations/ β†’  SQL schema migrations
β”‚   β”‚   └── redis/          β†’  Redis queue implementation
β”‚   β”œβ”€β”€ scheduler/          β†’  Job scheduling logic
β”‚   └── reaper/             β†’  Crash recovery service
β”‚
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ logging/            β†’  Structured JSON logger
β”‚   β”œβ”€β”€ metrics/            β†’  Prometheus metric definitions
β”‚   β”œβ”€β”€ middleware/          β†’  HTTP middleware (correlation IDs, etc.)
β”‚   └── retry/              β†’  Exponential backoff policies
β”‚
└── deployments/
    β”œβ”€β”€ docker-compose.yml
    └── prometheus.yml

πŸ” Observability

GoQueue treats observability as a first-class concern - not an afterthought.

Structured JSON Logging

Every log line carries a correlation_id for full request traceability:

{
  "level": "info",
  "correlation_id": "REQ-8472",
  "event": "job_processed",
  "job_id": "a1b2c3",
  "queue": "high",
  "worker": "worker-1",
  "duration_ms": 142
}

Prometheus Metrics

Exposed at /metrics - all critical signals tracked:

goqueue_jobs_enqueued_total        β†’  Total jobs submitted
goqueue_jobs_processed_total       β†’  Successfully processed
goqueue_jobs_failed_total          β†’  Failed jobs (by queue)
goqueue_queue_depth                β†’  Current queue depth (by priority)
goqueue_worker_utilization         β†’  Worker pool saturation %
goqueue_retry_count                β†’  Retry attempts in flight
goqueue_dlq_size                   β†’  Dead Letter Queue depth
goqueue_processing_latency_seconds β†’  Job processing duration histogram

Grafana Dashboards

Pre-built dashboards ship with the repo.

open http://localhost:3000   # after docker-compose up

⚑ Load Testing Results

Tested with k6 at high concurrency:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Load Test Summary (k6)            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Virtual Users       β”‚  10,000              β”‚
β”‚  Total Requests      β”‚  40,000+             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Backpressure (429)  β”‚  βœ… Validated        β”‚
β”‚  Crash Recovery      β”‚  βœ… All jobs back    β”‚
β”‚  DLQ Routing         β”‚  βœ… Clean isolation  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Language        β†’  Go
Persistence     β†’  PostgreSQL
Queue / Cache   β†’  Redis
Observability   β†’  Prometheus + Grafana
Infrastructure  β†’  Docker + Docker Compose

🀝 Contributing

Contributions are welcome - bug reports, feature suggestions, and pull requests alike.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/your-feature
  3. Commit your changes: git commit -m 'feat: add your feature'
  4. Push to the branch: git push origin feat/your-feature
  5. Open a Pull Request

Please read CONTRIBUTING.md before submitting - it covers running the test suite locally and the PR process.


πŸ“„ License

Licensed under the terms in LICENSE.


GoQueue v1.0

Built with ❀️ using Go · Redis · PostgreSQL · Prometheus · Grafana


⭐ Star this repo if GoQueue helped you! ⭐

About

Production-inspired distributed background job processing engine built with Go, Redis, and PostgreSQL. Features worker pools, retries, DLQ, crash recovery, scheduling, observability, idempotency, and backpressure handling.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages