Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submissão - Rodrigo Caldeira #32

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions participantes/rodrigocaldeira/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Submissão para Rinha de Backend, Segunda Edição: 2024/Q1 - Controle de Concorrência


<img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Nginx_logo.svg" alt="logo nginx" width="300" height="auto">
<br />
<img src="https://elixirforum.com/uploads/default/original/2X/d/d3c839623608f5e568f50c31c276a3f77f906903.png" alt="logo phoenix" width="200" height="auto">
<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" alt="logo postgres" width="200" height="auto">


## Rodrigo Caldeira
Submissão feita com:
- `nginx` como load balancer
- `postgres` como banco de dados
- `elixir` para api com o framework `phoenix` usando libs padrão do `mix phx.new`
- [repositório da api](https://github.com/rodrigocaldeira/rinha_backend_2024_q1)

[@rodrigocaldeira](https://twitter.com/rodrigocaldeira) @ twitter
85 changes: 85 additions & 0 deletions participantes/rodrigocaldeira/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
version: "3.5"

services:
api01: &api
hostname: api01
image: rodscaldeira/rinha-backend-2024-q1:latest
ports:
- "4000:4000"
environment:
- PHX_HOST=api01
- SECRET_KEY_BASE="vnbnYw4N0WzDuQieEpv0tzaZCAGfNOzk/M+naf87PNX3yd2fM4COTizm3yVwwHh7"
- DATABASE_URL=postgres://postgres:postgres@db:5432/rinha_backend
depends_on:
db:
condition: service_healthy
deploy:
resources:
limits:
cpus: "0.6"
memory: "200MB"
ulimits:
nproc: 65535
nofile:
soft: 1000000
hard: 1000000

api02:
<<: *api
hostname: api02
ports:
- "4001:4001"
depends_on:
- api01
environment:
- PORT=4001
- PHX_HOST=api02
- SECRET_KEY_BASE="yd5mZeRqTh7KqzvBGTPIaN9yuIRoeQuqeeQCJKe8pqAXakf1p4zugNYfUGjp32C+"
- DATABASE_URL=postgres://postgres:postgres@db:5432/rinha_backend

nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api01
- api02
ports:
- "9999:9999"
deploy:
resources:
limits:
cpus: "0.1"
memory: "50MB"
ulimits:
nproc: 65535
nofile:
soft: 1000000
hard: 1000000


db:
image: postgres:latest
hostname: db
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=rinha_backend
ports:
- "5432:5432"
deploy:
resources:
limits:
cpus: "0.20"
memory: "100MB"
command: postgres -c max_connections=450
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d rinha_backend" ]
interval: 3s
timeout: 1s
retries: 5

networks:
default:
driver: bridge
name: rinha_backend_2024_q1
22 changes: 22 additions & 0 deletions participantes/rodrigocaldeira/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
events {
worker_connections 8000;
use epoll;
}

http {
access_log off;
sendfile on;

upstream api {
server api01:4000;
server api02:4001;
}

server {
listen 9999;

location / {
proxy_pass http://api;
}
}
}
Loading