Skip to content

Commit

Permalink
Merge pull request #19 from zoedsoupe/elixiremfoco/solucao
Browse files Browse the repository at this point in the history
submissão elixiremfoco
  • Loading branch information
zanfranceschi authored Feb 7, 2024
2 parents 4e1aef3 + 8077583 commit 7e408ae
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
23 changes: 23 additions & 0 deletions participantes/elixiremfoco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Submissão para Rinha de Backend, Segunda Edição: 2024/Q1 - Controle de Concorrência

<div style="width: 100%; display: flex; justify-content: space-between;">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Nginx_logo.svg" alt="logo nginx" width="150" height="auto">
<img src="https://kagi.com/proxy/elixir_lang_logo_icon_169207.png?c=wwv2nwWrI4ROnanRegf-Un8ZW7RVAXok0DKYY-QUMejqyhLUewfi_6OQu3PWzbORfWXS5ppgGGONO930F7ctZeiFJ1wl0I6NXue89fcIrLTIzZwdAVuFbyxv812aVWSs" alt="logo elixir" width="150" height="auto">
<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" alt="logo postgres" width="150" height="auto">
<img src="https://kagi.com/proxy/phoenix3808.logowik.com.webp?c=pKaagLJLIb7Z701QOA8qEDP9t3K3-ePdFCDl2p_bpS3qGzKpfTWlRXoUGI1FRROeFf1gyqCJAX52I6wYC7VPMPs0YUCCHq9yBgyScIjoxLuhGx8VUOjWdeGTiK9UtxgX" alt="logo phoenix" width="150" height="auto">
</div>

## Elixir em Foco

Submissão feita com:

- `nginx` como load balancer
- `postgres` como banco de dados
- `elixir` para api com a lib `phoenix`
- [repositório da api](https://github.com/ElixiremFoco/rinha-backend-2024-q1)

100% success rate, 11ms mean response time

[portal elixiremfoco](https://www.elixiremfoco.com/)
[@herminiotorres](https://twitter.com/herminiotorres)@twitter
[@zoedsoupe](https://bsky.app/profile/zoedsoupe.bsky.social)@bsky
73 changes: 73 additions & 0 deletions participantes/elixiremfoco/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
version: "3.5"

services:
api01: &api
image: ghcr.io/elixiremfoco/rinha-backend-2024-q1:latest
hostname: api01
environment:
- PHX_HOST=api01
- SECRET_KEY_BASE="HScbRLB0u8vOQAMWLC2DFHdrpnMKcGEs"
- DATABASE_URL=postgresql://postgres:postgres@db:5432/rinha

ports:
- "4000:4000"
depends_on:
db:
condition: service_healthy
deploy:
resources:
limits:
cpus: "0.6"
memory: "200MB"

api02:
<<: *api
hostname: api02
environment:
- PORT=4001
- PHX_HOST=api02
- SECRET_KEY_BASE="ZufWuBc1xg3ssETNHHB14bZ1PKM1mruC"
- DATABASE_URL=postgresql://postgres:postgres@db:5432/rinha
ports:
- "4001:4001"

nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api01
- api02
ports:
- "9999:9999"
deploy:
resources:
limits:
cpus: "0.17"
memory: "10MB"

db:
image: postgres:latest
hostname: db
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=rinha
ports:
- "5432:5432"
deploy:
resources:
limits:
cpus: "0.13"
memory: "140MB"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d rinha" ]
interval: 3s
timeout: 1s
retries: 2

networks:
default:
driver: bridge
name: rinha-nginx-2024q1

22 changes: 22 additions & 0 deletions participantes/elixiremfoco/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
events {
worker_connections 1000;
}

http {
access_log off;
sendfile on;

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

server {
listen 9999;

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

0 comments on commit 7e408ae

Please sign in to comment.