forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Submissão Wallace (zanfranceschi#1672)
- Loading branch information
1 parent
e3f3b3a
commit b1096b6
Showing
4 changed files
with
108 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,7 @@ | ||
**<center>API feita em Python com FastAPI, PostgreSQL e NGINX</center>** | ||
|
||
|
||
Repositório da API: [WallacePinho/rinha-backend-2024-q1-fastapi](https://github.com/WallacePinho/rinha-backend-2024-q1-fastapi) | ||
<br> | ||
Contato: [LinkedIn](https://www.linkedin.com/in/wallacepinho/) | ||
|
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,56 @@ | ||
version: "3.5" | ||
|
||
services: | ||
api1: &api | ||
image: wallacepinho/rinha-backend-2024-q1-fastapi | ||
hostname: api1 | ||
environment: | ||
- PYTHONPATH=/code/app | ||
depends_on: | ||
- postgres | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.5" | ||
memory: "200MB" | ||
|
||
api2: | ||
<<: *api | ||
hostname: api2 | ||
|
||
nginx: | ||
image: nginx:latest | ||
volumes: | ||
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro | ||
depends_on: | ||
- api1 | ||
- api2 | ||
ports: | ||
- "9999:9999" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.25" | ||
memory: "10MB" | ||
|
||
postgres: | ||
image: postgres:16.2 | ||
hostname: postgres | ||
environment: | ||
- POSTGRES_PASSWORD=rinha | ||
- POSTGRES_USER=rinha | ||
- POSTGRES_DB=rinha | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- ./database:/docker-entrypoint-initdb.d/ | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.25" | ||
memory: "140MB" | ||
|
||
networks: | ||
default: | ||
driver: bridge | ||
name: rinha-backend-2024-q1 |
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,21 @@ | ||
events { | ||
worker_connections 1000; | ||
} | ||
|
||
http { | ||
access_log off; | ||
sendfile on; | ||
|
||
upstream api { | ||
server api1:80; | ||
server api2:80; | ||
} | ||
|
||
server { | ||
listen 9999; | ||
|
||
location / { | ||
proxy_pass http://api; | ||
} | ||
} | ||
} |
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,24 @@ | ||
create schema rinha; | ||
|
||
-- tables | ||
create table rinha.cliente ( | ||
id integer, | ||
limite integer, | ||
saldo integer | ||
); | ||
|
||
create table rinha.transacao ( | ||
cliente_id integer, | ||
valor integer, | ||
tipo varchar(1), | ||
descricao varchar(10), | ||
realizada_em timestamp | ||
); | ||
|
||
-- data | ||
insert into rinha.cliente(id, limite, saldo) values | ||
(1, 100000, 0), | ||
(2, 80000, 0), | ||
(3, 1000000, 0), | ||
(4, 10000000, 0), | ||
(5, 500000, 0); |