Skip to content

Repository files navigation

High-Performance Resilient Task Queue Service

A distributed payment processing architecture focused on high performance, strict idempotency, and system resilience.

🌟 About the Developer

Hello! I'm Ezequiel Ranieri. I am a self-taught developer who discovered the world of programming through curiosity and a passion for building things. Everything I know—from architecture patterns to distributed systems—I've learned on my own through books, technical documentation, videos, and endless hours of practice.

I created this project to consolidate and demonstrate my understanding of high-performance backend systems. I don't claim to be a senior architect; I am a dedicated learner who enjoys solving complex technical challenges and building robust software that works under pressure.

Contact:


🏗 System Architecture

This service is designed to handle critical tasks (like payment processing) where data integrity and reliability are non-negotiable.

Data Flow:

  1. Ingestion (FastAPI): A high-performance gateway receives requests and provides a "Cache-aside" status query endpoint.
  2. Queuing (RabbitMQ): Messages are routed through priority exchanges (high_priority, default, low_priority).
  3. Idempotency Filter (Redis): Before processing, workers check atomic locks in Redis to prevent duplicate executions (Strict Idempotency).
  4. Processing (Celery Workers): Workers consume tasks using a prefetch-multiplier=1 strategy for fair distribution.
  5. Resilience: Tasks implement Exponential Backoff with Jitter to handle transient 5xx errors without overloading third-party APIs.
  6. Persistence (PostgreSQL): Every successful or terminal state is persisted for audit and long-term storage.
  7. Dead Letter Queue (DLQ): Tasks that exhaust all 5 retries are diverted to a dedicated queue for manual auditing.

🛠 Tech Stack

  • FastAPI: Asynchronous API for querying task status.
  • Celery: Distributed task queue framework.
  • RabbitMQ: Robust message broker for inter-service communication.
  • Redis: High-speed idempotency lock and result backend.
  • PostgreSQL: Relational database for persistent records.
  • Docker & Compose: Containerization for consistent environments.
  • Locust: Stress testing to validate the system under load.

🚀 Quick Start Guide

1. Prerequisites

2. Configuration

Clone the repository and set up your environment variables:

git clone https://github.com/ezequielranieri/high-performance-task-queue
cd high-performance-task-queue
cp .env.example .env

(Note: You can use the default values in .env for local testing).

3. Deployment

Spin up the entire infrastructure with a single command:

docker compose up -d

The system will automatically initialize the databases and start the workers.

4. Verification


📊 Load Testing & Resiliency Verification

To validate the system's performance and reliability, I performed a stress test simulating a high-traffic scenario. The results demonstrate the architecture's ability to maintain high throughput while ensuring data integrity.

📈 Metrics Overview

  • Throughput: Sustained ~160 Requests Per Second (RPS) with 50 concurrent users.
  • Volume: Successfully processed over 20,000 tasks in a single burst.
  • Latency: Sub-millisecond response times from the API gateway (FastAPI), thanks to its asynchronous nature.

🛡️ Resiliency & Observability

The following dashboards confirm the system's stability under pressure:

1. Locust Benchmark

Locust Benchmark Visualizes the linear scaling of RPS and stable response times during the stress test.

2. RabbitMQ Queue Management

RabbitMQ Queues Shows the three priority queues (high, default, low) handling the burst efficiently and the DLQ (Dead Letter Queue) ready to capture exhausted retries.

3. Flower Monitoring (Celery Resiliency)

Flower Dashboard Critical validation point: The task list shows active retries with Exponential Backoff. This confirms that the worker identifies transient failures and waits incrementally longer between attempts, preventing cascading failures.

4. Strict Idempotency

During the test, I injected duplicate payment_id values. The system correctly identified these using Redis SETNX, blocking the redundant task execution and returning the cached status, ensuring that no payment was processed twice.


🧠 What I Learned

Developing this project was a significant milestone in my self-taught journey. Some key takeaways include:

  • Managing Distributed State: Using Redis for atomic operations and idempotency.
  • Handling Failure Gracefully: Understanding the difference between retryable (5xx) and terminal (4xx) errors.
  • Orchestration: Managing multiple services with Docker Compose and ensuring proper startup sequences with health checks.
  • Performance Testing: Using Locust to find bottlenecks and observing how prefetch settings impact worker efficiency.

Thank you for checking out my work! I'm always open to feedback and looking for new opportunities to learn and grow.

About

asynchronous payment microservice with strict idempotency and resilience patterns. powered by FastAPI, Celery, RabbitMQ, Redis, and PostgreSQL.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages