From 22714792d813dc06ae152eb82f7b84fd9b5ef64e Mon Sep 17 00:00:00 2001 From: Tenshy <51997934+Tenshyn@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:57:57 -0300 Subject: [PATCH 1/3] =?UTF-8?q?Configura=C3=A7=C3=A3o=20do=20nginx=20e=20d?= =?UTF-8?q?ocker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- participantes/thiagoGomes/docker-compose.yml | 69 ++++++++++++++++++++ participantes/thiagoGomes/nginx.conf | 35 ++++++++++ 2 files changed, 104 insertions(+) create mode 100644 participantes/thiagoGomes/docker-compose.yml create mode 100644 participantes/thiagoGomes/nginx.conf diff --git a/participantes/thiagoGomes/docker-compose.yml b/participantes/thiagoGomes/docker-compose.yml new file mode 100644 index 0000000..adcf049 --- /dev/null +++ b/participantes/thiagoGomes/docker-compose.yml @@ -0,0 +1,69 @@ +services: + api01: &api + image: tenshinran/test-backend:latest + hostname: api01 + environment: + - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/transaction + - SPRING_DATASOURCE_USERNAME=admin + - SPRING_DATASOURCE_PASSWORD=123 + - SPRING_DATASOURCE_HIKARI_MAXIMUM-POOL-SIZE=10 + - SPRING_DATASOURCE_HIKARI_MINIMUM-IDLE=5 + - SERVER_PORT=3000 + ports: + - "3001:3000" + depends_on: + - db + deploy: + resources: + + limits: + cpus: "0.55" + memory: "200MB" + + api02: + <<: *api + hostname: api02 + ports: + - "3002:3000" + + nginx: + image: nginx:latest + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - api01 + - api02 + ports: + - "9999:9999" + sysctls: + - net.ipv4.ip_local_port_range=10000 65535 + - net.ipv4.tcp_tw_reuse=1 + - net.ipv4.tcp_fin_timeout=30 + deploy: + resources: + limits: + cpus: "0.15" + memory: "10MB" + + db: + image: postgres:latest + hostname: db + environment: + - POSTGRES_PASSWORD=123 + - POSTGRES_USER=admin + - POSTGRES_DB=transaction + ports: + - "5432:5432" + volumes: + - ./init.sql:/docker-entrypoint-initdb.d/init.sql + command: postgres -c checkpoint_timeout=600 -c max_wal_size=4096 -c synchronous_commit=0 -c full_page_writes=0 + deploy: + resources: + limits: + cpus: "0.25" + memory: "140MB" + +networks: + default: + driver: bridge + name: net-nginx-test-backend diff --git a/participantes/thiagoGomes/nginx.conf b/participantes/thiagoGomes/nginx.conf new file mode 100644 index 0000000..20fdb4e --- /dev/null +++ b/participantes/thiagoGomes/nginx.conf @@ -0,0 +1,35 @@ +events { + worker_connections 2000; +} + +http { + access_log off; + sendfile on; + + keepalive_timeout 65; + keepalive_requests 1000; + + upstream api { + server api01:3000; + server api02:3000; + keepalive 64; + keepalive_requests 1000; + keepalive_timeout 60s; + } + + server { + listen 9999; + + location / { + proxy_pass http://api; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_set_header Host $host; + + # Buffering + proxy_buffering on; + proxy_buffer_size 4k; + proxy_buffers 8 4k; + } + } +} \ No newline at end of file From 4b729fae25acc67baaed9891be107be98b009041 Mon Sep 17 00:00:00 2001 From: Tenshy <51997934+Tenshyn@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:58:15 -0300 Subject: [PATCH 2/3] =?UTF-8?q?Cria=C3=A7=C3=A3o=20do=20script=20de=20inic?= =?UTF-8?q?ializa=C3=A7=C3=A3o=20do=20banco=20de=20dados=20com=20as=20tabe?= =?UTF-8?q?las=20necess=C3=A1rias=20e=20dados=20pr=C3=A9-cadastrados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- participantes/thiagoGomes/init.sql | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 participantes/thiagoGomes/init.sql diff --git a/participantes/thiagoGomes/init.sql b/participantes/thiagoGomes/init.sql new file mode 100644 index 0000000..77b86bf --- /dev/null +++ b/participantes/thiagoGomes/init.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS client ( + id INT PRIMARY KEY, + client_limit INT NOT NULL, + balance INT NOT NULL +); + +INSERT INTO client (id, client_limit, balance) VALUES (1, 100000, 0); +INSERT INTO client (id, client_limit, balance) VALUES (2, 80000, 0); +INSERT INTO client (id, client_limit, balance) VALUES (3, 1000000, 0); +INSERT INTO client (id, client_limit, balance) VALUES (4, 10000000, 0); +INSERT INTO client (id, client_limit, balance) VALUES (5, 500000, 0); + +CREATE TABLE IF NOT EXISTS transaction ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + value INT NOT NULL, + type INT NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + description VARCHAR(10), + client_id INT NOT NULL, + CONSTRAINT fk_client FOREIGN KEY (client_id) REFERENCES client(id) +); + +CREATE INDEX idx_transaction_client_id ON transaction(client_id); +CREATE INDEX idx_transaction_created_at ON transaction(created_at DESC); From 8f64e1f75b440e49ed67019ae7fb8b006273a6d6 Mon Sep 17 00:00:00 2001 From: Tenshy <51997934+Tenshyn@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:58:50 -0300 Subject: [PATCH 3/3] =?UTF-8?q?Cria=C3=A7=C3=A3o=20do=20README.md=20indica?= =?UTF-8?q?ndo=20tecnologias=20usadas=20e=20url=20para=20reposit=C3=B3rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- participantes/thiagoGomes/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 participantes/thiagoGomes/README.md diff --git a/participantes/thiagoGomes/README.md b/participantes/thiagoGomes/README.md new file mode 100644 index 0000000..13bd4ba --- /dev/null +++ b/participantes/thiagoGomes/README.md @@ -0,0 +1,15 @@ +# Submissão Teste Backend - Controle de Concorrência + +logo nginx +
+logo clojure +logo postgres + +## Thiago Gonçalves Gomes + +Submissão feita com: + +- `nginx` como load balancer +- `postgres` como banco de dados +- `Java` para api com `Spring` +- [repositório da api](https://github.com/Tenshyn/transactions)