-
Notifications
You must be signed in to change notification settings - Fork 933
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 #57 from Aysion/aysion
Aysion - nodeJS
- Loading branch information
Showing
4 changed files
with
114 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,15 @@ | ||
# 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://upload.wikimedia.org/wikipedia/commons/7/7e/Node.js_logo_2015.svg" alt="logo nodeJS" width="200" height="auto"> | ||
<img src="https://upload.wikimedia.org/wikipedia/commons/6/68/Mariadb-seal-browntext.svg" alt="logo mariaDB" width="200" height="auto"> | ||
|
||
|
||
## Aysion | ||
Submissão feita com: | ||
- `nginx` como load balancer | ||
- `mariaDB` como banco de dados | ||
- `nodeJS` para api com a lib `mysql2` | ||
- [repositório da api](https://github.com/aysion/rinha_de_backend_2024_q1-nodejs) | ||
[@aysiondenosfero](https://twitter.com/aysiondenosfero) @ twitter |
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,52 @@ | ||
version: "3.9" | ||
|
||
services: | ||
api_01: &api | ||
image: aysion/rinha_de_backend_2024_q1-nodejs | ||
restart: unless-stopped | ||
hostname: api_01 | ||
environment: | ||
- PORT=8080 | ||
depends_on: | ||
- db | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.15" | ||
memory: "120MB" | ||
api_02: | ||
<<: *api | ||
hostname: api_02 | ||
nginx: | ||
image: nginx:latest | ||
restart: unless-stopped | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf | ||
depends_on: | ||
- api_01 | ||
- api_02 | ||
ports: | ||
- 9999:9999 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.2" | ||
memory: "10MB" | ||
db: | ||
image: mariadb:11 | ||
restart: unless-stopped | ||
hostname: db | ||
environment: | ||
- MARIADB_ROOT_PASSWORD=adminPass | ||
- MARIADB_DATABASE=rinha | ||
volumes: | ||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "1" | ||
memory: "300MB" | ||
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,25 @@ | ||
USE rinha; | ||
|
||
CREATE TABLE clientes ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
nome VARCHAR(50), | ||
limite INT DEFAULT 0, | ||
saldo INT DEFAULT 0 | ||
); | ||
|
||
CREATE TABLE transacoes ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
cliente_id INT, | ||
valor INT, | ||
tipo ENUM('d', 'c'), | ||
descricao VARCHAR(10), | ||
realizada_em TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
FOREIGN KEY (cliente_id) REFERENCES clientes(id) | ||
); | ||
|
||
INSERT INTO clientes (nome, limite) VALUES | ||
('o barato sai caro', 1000 * 100), | ||
('zan corp ltda', 800 * 100), | ||
('les cruders', 10000 * 100), | ||
('padaria joia de cocaia', 100000 * 100), | ||
('kid mais', 5000 * 100); |
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 256; | ||
} | ||
|
||
http { | ||
access_log off; | ||
sendfile on; | ||
keepalive_timeout 0; | ||
|
||
upstream api { | ||
server api_01:8080; | ||
server api_02:8080; | ||
} | ||
|
||
server { | ||
listen 9999; | ||
|
||
location / { | ||
proxy_pass http://api; | ||
} | ||
} | ||
} |