diff --git a/participantes/aysion_nodejs/README.md b/participantes/aysion_nodejs/README.md new file mode 100644 index 000000000..35d6d27df --- /dev/null +++ b/participantes/aysion_nodejs/README.md @@ -0,0 +1,15 @@ +# Submissão para Rinha de Backend, Segunda Edição: 2024/Q1 - Controle de Concorrência + +logo nginx +
+logo nodeJS +logo mariaDB + + +## 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 diff --git a/participantes/aysion_nodejs/docker-compose.yml b/participantes/aysion_nodejs/docker-compose.yml new file mode 100644 index 000000000..2af243a95 --- /dev/null +++ b/participantes/aysion_nodejs/docker-compose.yml @@ -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 diff --git a/participantes/aysion_nodejs/init.sql b/participantes/aysion_nodejs/init.sql new file mode 100644 index 000000000..a1ebef71e --- /dev/null +++ b/participantes/aysion_nodejs/init.sql @@ -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); diff --git a/participantes/aysion_nodejs/nginx.conf b/participantes/aysion_nodejs/nginx.conf new file mode 100644 index 000000000..33fcde3b9 --- /dev/null +++ b/participantes/aysion_nodejs/nginx.conf @@ -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; + } + } +}