From 1cdbc9cd9fc5d4c18a3b53741408824393d3d1cc Mon Sep 17 00:00:00 2001 From: Vitor Breno Gomes da Silva <40612400+vitor-bgs@users.noreply.github.com> Date: Sun, 10 Mar 2024 22:11:30 -0300 Subject: [PATCH] adiciona participante vitorbgs (#1642) --- participantes/vitorbgs/docker-compose.yml | 62 +++++++++++++++++++++++ participantes/vitorbgs/nginx.conf | 29 +++++++++++ participantes/vitorbgs/readme.md | 19 +++++++ participantes/vitorbgs/script.sql | 43 ++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 participantes/vitorbgs/docker-compose.yml create mode 100644 participantes/vitorbgs/nginx.conf create mode 100644 participantes/vitorbgs/readme.md create mode 100644 participantes/vitorbgs/script.sql diff --git a/participantes/vitorbgs/docker-compose.yml b/participantes/vitorbgs/docker-compose.yml new file mode 100644 index 000000000..de1faccd6 --- /dev/null +++ b/participantes/vitorbgs/docker-compose.yml @@ -0,0 +1,62 @@ +version: "3.8" + +services: + api01: &api + image: vitorbgs/crebito-rinha-backend-2024q1 + hostname: api01 + environment: + - ASPNETCORE_ENVIRONMENT=Loadtest + - ConnectionStrings__CrebitoDbConnection=Host=db;Database=rinha;Username=admin;Password=123;Maximum Pool Size=4; + ports: + - "8081:8080" + depends_on: + - db + deploy: + resources: + limits: + cpus: "0.4" + memory: "70MB" + + api02: + <<: *api + hostname: api02 + ports: + - "8080:8080" + + nginx: + image: nginx:latest + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - api01 + - api02 + ports: + - "9999:9999" + deploy: + resources: + limits: + cpus: "0.2" + memory: "20MB" + + db: + image: postgres:latest + hostname: db + environment: + - POSTGRES_PASSWORD=123 + - POSTGRES_USER=admin + - POSTGRES_DB=rinha + command: 'postgres -c max_connections=20 -c shared_buffers=128MB -c effective_cache_size=256MB -c synchronous_commit=off -c fsync=off -c full_page_writes=off' + ports: + - "5432:5432" + volumes: + - ./script.sql:/docker-entrypoint-initdb.d/script.sql + deploy: + resources: + limits: + cpus: "0.5" + memory: "390MB" + +networks: + default: + driver: bridge + name: rinha-nginx-2024q1 diff --git a/participantes/vitorbgs/nginx.conf b/participantes/vitorbgs/nginx.conf new file mode 100644 index 000000000..aca1fd85a --- /dev/null +++ b/participantes/vitorbgs/nginx.conf @@ -0,0 +1,29 @@ +events { + worker_connections 512; +} + + +http { + upstream api { + server api01:8080; + server api02:8080; + } + + server { + listen 9999; + access_log off; + location / { + proxy_buffering off; + proxy_set_header Connection ""; + proxy_http_version 1.1; + proxy_set_header Keep-Alive ""; + proxy_set_header Proxy-Connection "keep-alive"; + proxy_pass http://api; + + # Timeouts + proxy_connect_timeout 30s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + } + } +} \ No newline at end of file diff --git a/participantes/vitorbgs/readme.md b/participantes/vitorbgs/readme.md new file mode 100644 index 000000000..dd231b266 --- /dev/null +++ b/participantes/vitorbgs/readme.md @@ -0,0 +1,19 @@ +## Rinha de Backend 2024q1 - vitorbgs + +### Tecnologias +- .NET 8 + - Minimal API + - Clean Architecture + - FluentValidation + - Dapper +- PostgreSQL +- NGINX + +### Resultados +![image](https://github.com/vitor-bgs/crebito-rinha-backend-2024q1/assets/40612400/2990e35b-bf1a-47c4-bd62-c631706cf517) + + +### Info +Repositório da Rinha: [zanfranceschi/rinha-de-backend-2024-q1](https://github.com/zanfranceschi/rinha-de-backend-2024-q1) + +LinkedIn: [Vitor Breno Gomes da Silva](https://www.linkedin.com/in/vitorbgs/) \ No newline at end of file diff --git a/participantes/vitorbgs/script.sql b/participantes/vitorbgs/script.sql new file mode 100644 index 000000000..650c7a606 --- /dev/null +++ b/participantes/vitorbgs/script.sql @@ -0,0 +1,43 @@ +-- Table: public.contas + +-- DROP TABLE IF EXISTS public.contas; + +CREATE TABLE IF NOT EXISTS public.contas +( + id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), + cliente_id integer NOT NULL, + limite integer NOT NULL, + saldo integer NOT NULL, + CONSTRAINT pk_clientes PRIMARY KEY (id) +); + +CREATE INDEX IF NOT EXISTS idx_contas_cliente_id ON public.contas(cliente_id); + +-- Table: public.Transacoes + +-- DROP TABLE IF EXISTS public.transacoes; + +CREATE TABLE IF NOT EXISTS public.transacoes +( + id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), + conta_id integer NOT NULL, + tipo character(1) COLLATE pg_catalog."default" NOT NULL, + descricao text COLLATE pg_catalog."default" NOT NULL, + valor integer NOT NULL, + realizada_em timestamp with time zone NOT NULL, + CONSTRAINT pk_transacoes PRIMARY KEY (id) +); +CREATE INDEX IF NOT EXISTS idx_transacoes_conta_id ON public.transacoes(conta_id); + + +DELETE FROM public.contas; +DELETE FROM public.transacoes; + +INSERT INTO public.contas(cliente_id, limite, saldo) + VALUES + (1, 100000, 0), + (2, 80000, 0), + (3, 1000000, 0), + (4, 10000000, 0), + (5, 500000, 0); +