Learning Project — Based on .NET Implementation

Rinha de Backend
Python Implementation

A Python reimplementation of the Rinha de Backend competition API, built for learning purposes. Based on the .NET version that achieved a perfect score in the official competition.

The Competition

The Rinha de Backend - Segunda Edicao was a performance competition where developers built HTTP APIs handling financial transactions (credits/debits) under strict resource constraints. The APIs had to manage concurrent load while maintaining data consistency — all within tight CPU and memory limits enforced via Docker.

Two endpoints were required: POST /clientes/{id}/transacoes for processing transactions and GET /clientes/{id}/extrato for account statements. The evaluation criteria were brutal: 98% of responses under 250ms and zero balance inconsistencies.

📚
This implementation is based on the rinha2-back-end-dotnet project, which achieved a perfect score (USD 100,000, zero penalties) in the official competition. This Python version was built afterward as a learning exercise to explore Flask, Gunicorn, and psycopg2 in a high-performance context.
# infrastructure
nginx :9999 → load balancer (least_conn)
  api-01 :8080 → Flask + Gunicorn (4w x 2t)
  api-02 :8080 → Flask + Gunicorn (4w x 2t)
postgres :5432 → database (PLpgSQL stored procedures)

# constraints
total: 1.5 vCPU + 550MB RAM

Original .NET Score

The original .NET implementation that this project is based on achieved a perfect score in the official Rinha de Backend competition — zero penalties across both evaluation criteria.

🏆 jonathanperis — rinha2-back-end-dotnet
SLA Penalty (>249ms)
USD 0.00
Consistency Penalty
USD 0.00
Total Penalty
USD 0.00
Final Score
USD 100,000

Built With

Python 3.11 / Flask
Lightweight WSGI framework
Gunicorn
WSGI HTTP server (4w x 2t)
psycopg2
PostgreSQL adapter
PostgreSQL
PLpgSQL stored procedures
Nginx
Reverse proxy, load balancer
Docker
Multi-platform builds
Grafana K6
Load testing, HTML reports
Prometheus + Grafana
Metrics & monitoring

K6 Load Test Reports

Reports generated automatically via GitHub Actions on every push to main. Previously built on Gatling/Scala, now migrated to Grafana K6 for native CI/CD integration.

Loading reports...

K6 Test Suite

All implementations are validated by the same Grafana K6 stress test suite, originally written in Gatling/Scala.

Rinha de Backend Family

Other implementations of the same challenge, sharing the same PostgreSQL stored-procedure strategy.