From ec814d94034a842f7fc247a10583def70d2c487a Mon Sep 17 00:00:00 2001 From: Giovanni Bassi Date: Tue, 22 Aug 2023 23:56:17 -0300 Subject: [PATCH] Adiciona Giovanni --- participantes/giovannibassi/README.md | 3 + participantes/giovannibassi/ddl.sql | 24 +++++ .../giovannibassi/docker-compose.yml | 101 ++++++++++++++++++ participantes/giovannibassi/nginx.conf | 21 ++++ 4 files changed, 149 insertions(+) create mode 100644 participantes/giovannibassi/README.md create mode 100644 participantes/giovannibassi/ddl.sql create mode 100644 participantes/giovannibassi/docker-compose.yml create mode 100644 participantes/giovannibassi/nginx.conf diff --git a/participantes/giovannibassi/README.md b/participantes/giovannibassi/README.md new file mode 100644 index 00000000..44173dbe --- /dev/null +++ b/participantes/giovannibassi/README.md @@ -0,0 +1,3 @@ +# Rinha App com ASP.NET 8 (Preview 7) + +Veja mais no repo: diff --git a/participantes/giovannibassi/ddl.sql b/participantes/giovannibassi/ddl.sql new file mode 100644 index 00000000..ae4c424d --- /dev/null +++ b/participantes/giovannibassi/ddl.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( + "MigrationId" character varying(150) NOT NULL, + "ProductVersion" character varying(32) NOT NULL, + CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") +); + +START TRANSACTION; + +CREATE TABLE "Pessoas" ( + "Id" uuid NOT NULL, + "Apelido" character varying(32) NOT NULL, + "Nome" character varying(100) NOT NULL, + "Nascimento" date NOT NULL, + "Stack" text[], + CONSTRAINT "PK_Pessoas" PRIMARY KEY ("Id") +); + +CREATE UNIQUE INDEX "IX_Pessoas_Apelido" ON "Pessoas" ("Apelido"); + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20230823002823_First', '8.0.0-preview.7.23375.4'); + +COMMIT; + diff --git a/participantes/giovannibassi/docker-compose.yml b/participantes/giovannibassi/docker-compose.yml new file mode 100644 index 00000000..4c58c635 --- /dev/null +++ b/participantes/giovannibassi/docker-compose.yml @@ -0,0 +1,101 @@ +version: '3.9' +name: 'rinha-giovannibassi' + +services: + api1: + image: giggio/rinhabackend-2023-q3 + hostname: api1 + environment: + - ConnectionStrings__Rinha=Host=db;Database=rinha;Username=rinha;Password=rinha + depends_on: + db: + condition: service_healthy + ulimits: + nofile: + soft: 1000000 + hard: 1000000 + deploy: + resources: + limits: + cpus: '0.5' + memory: '960MB' + networks: + - app-network + healthcheck: + test: curl -o /dev/null -fs --retry 0 --head http://localhost:5000/healthz || exit 1 + interval: 10s + retries: 3 + start_period: 5s + timeout: 2s + + api2: + image: giggio/rinhabackend-2023-q3 + hostname: api2 + environment: + - ConnectionStrings__Rinha=Host=db;Database=rinha;Username=rinha;Password=rinha + depends_on: + db: + condition: service_healthy + ulimits: + nofile: + soft: 1000000 + hard: 1000000 + deploy: + resources: + limits: + cpus: '0.5' + memory: '960MB' + networks: + - app-network + healthcheck: + test: curl -o /dev/null -fs --retry 0 --head http://localhost:5000/healthz || exit 1 + interval: 10s + retries: 3 + start_period: 5s + timeout: 2s + + nginx: + image: nginx:latest + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - api1 + - api2 + ports: + - "9999:9999" + networks: + - app-network + deploy: + resources: + limits: + cpus: '0.1' + memory: '128MB' + + db: + image: postgres:latest + command: 'postgres -c max_connections=200 -c shared_buffers=256MB -c synchronous_commit=off -c fsync=off -c full_page_writes=off' + hostname: db + environment: + - POSTGRES_PASSWORD=rinha + - POSTGRES_USER=rinha + - POSTGRES_DB=rinha + ports: + - "5432:5432" + volumes: + - ./ddl.sql:/docker-entrypoint-initdb.d/ddl.sql + deploy: + resources: + limits: + cpus: '0.4' + memory: '1GB' + networks: + - app-network + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 5s + timeout: 5s + retries: 20 + start_period: 10s + +networks: + app-network: diff --git a/participantes/giovannibassi/nginx.conf b/participantes/giovannibassi/nginx.conf new file mode 100644 index 00000000..e3d28420 --- /dev/null +++ b/participantes/giovannibassi/nginx.conf @@ -0,0 +1,21 @@ +events { + worker_connections 10000; +} +http { + access_log off; + error_log off; + + upstream api { + least_conn; + server api1:5000; + server api2:5000; + } + + server { + listen 9999; + + location / { + proxy_pass http://api; + } + } +}