-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from zoedsoupe/elixiremfoco/solucao
submissão elixiremfoco
- Loading branch information
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
|