Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Mafra da Costa <[email protected]>
  • Loading branch information
gmafrac committed Mar 11, 2024
2 parents dc8241c + 1cdbc9c commit 02e053f
Show file tree
Hide file tree
Showing 95 changed files with 6,514 additions and 952 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Specifies a parent image
FROM golang:1.22.0-alpine3.19

# Creates an app directory to hold your app’s source code
WORKDIR /app
ADD . /app

# Copies everything from your root directory into /app
COPY . .

# Installs Go dependencies
RUN go mod download

# Builds your app with optional configuration
RUN go build -o /godocker

# Tells Docker which network port your container listens on
EXPOSE 8080

# Specifies the executable command that runs when the container starts
CMD [ "/godocker" ]
8 changes: 7 additions & 1 deletion STATUS-TESTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Status da Execução dos Testes
Tabela com os status das execuções de testes para cada submissão.

Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
Atualizada **Mon Mar 11 00:27:13 UTC 2024** com **707** submissões.

| participante | status | p75 geral |
| -- | -- | -- |
Expand Down Expand Up @@ -64,6 +64,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [andrepiske-01](./participantes/andrepiske-01) | falha - [logs](./participantes/andrepiske-01/docker-compose.logs) | -- |
| [andrepraeiro](./participantes/andrepraeiro) | ok | 2 |
| [andresantos-tech-PHP](./participantes/andresantos-tech-PHP) | ok | 3 |
| [andresantos-tech-PHP2](./participantes/andresantos-tech-PHP2) | ok | 2 |
| [andretpc](./participantes/andretpc) | ok | 1 |
| [andrew-vasco](./participantes/andrew-vasco) | ok | 3 |
| [anibal.ferreira](./participantes/anibal.ferreira) | ok | 2 |
Expand Down Expand Up @@ -121,6 +122,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [carloseduard0](./participantes/carloseduard0) | ok | 1 |
| [carls-rodrigues](./participantes/carls-rodrigues) | ok | 1 |
| [carlsonsantana-springboot](./participantes/carlsonsantana-springboot) | ok | 2 |
| [carolinejk-fastapi](./participantes/carolinejk-fastapi) | falha - [logs](./participantes/carolinejk-fastapi/docker-compose.logs) | -- |
| [casanje](./participantes/casanje) | falha - [logs](./participantes/casanje/docker-compose.logs) | -- |
| [cassiano-manuelzinho-golang](./participantes/cassiano-manuelzinho-golang) | ok | 2 |
| [cassiano-matheuszinho-java](./participantes/cassiano-matheuszinho-java) | falha - [logs](./participantes/cassiano-matheuszinho-java/docker-compose.logs) | -- |
Expand Down Expand Up @@ -192,6 +194,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [emanuel-xavier](./participantes/emanuel-xavier) | ok | 2 |
| [emiliosheinz-fumegalli-node](./participantes/emiliosheinz-fumegalli-node) | ok | 4 |
| [engylemure](./participantes/engylemure) | ok | 3 |
| [erick-lucca-nodejs](./participantes/erick-lucca-nodejs) | ok | 6 |
| [erickcestari](./participantes/erickcestari) | ok | 5 |
| [erickmarx](./participantes/erickmarx) | ok | 2 |
| [erickreis](./participantes/erickreis) | ok | 3 |
Expand Down Expand Up @@ -289,6 +292,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [guihbc](./participantes/guihbc) | ok | 277 |
| [guilherme-dotnet8](./participantes/guilherme-dotnet8) | ok | 1 |
| [gusinacio](./participantes/gusinacio) | falha - [logs](./participantes/gusinacio/docker-compose.logs) | -- |
| [gustavo-node-v2](./participantes/gustavo-node-v2) | ok | 22 |
| [gustavo-node](./participantes/gustavo-node) | ok | 1 |
| [gustavofbreunig](./participantes/gustavofbreunig) | ok | 3 |
| [gustavonovaes-go](./participantes/gustavonovaes-go) | ok | 2 |
Expand Down Expand Up @@ -335,6 +339,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [jhonnyboy](./participantes/jhonnyboy) | ok | 1 |
| [jjeanjacques10](./participantes/jjeanjacques10) | ok | 2 |
| [jnariai](./participantes/jnariai) | falha - [logs](./participantes/jnariai/docker-compose.logs) | -- |
| [jndavidx](./participantes/jndavidx) | ok | 2 |
| [joao0212](./participantes/joao0212) | ok | 1 |
| [joaobittencourt-php](./participantes/joaobittencourt-php) | falha - [logs](./participantes/joaobittencourt-php/docker-compose.logs) | -- |
| [joaojr13](./participantes/joaojr13) | ok | 3 |
Expand Down Expand Up @@ -571,6 +576,7 @@ Atualizada **Sun Mar 10 23:52:01 UTC 2024** com **701** submissões.
| [rhsobr-bun](./participantes/rhsobr-bun) | ok | 2 |
| [rhsobr-go](./participantes/rhsobr-go) | ok | 1 |
| [ricardovhz](./participantes/ricardovhz) | ok | 2 |
| [richardnfag-vernal](./participantes/richardnfag-vernal) | ok | 40492 |
| [rigottig](./participantes/rigottig) | ok | 6 |
| [ritilopes](./participantes/ritilopes) | ok | 1 |
| [rizzo-nodejs](./participantes/rizzo-nodejs) | falha - [logs](./participantes/rizzo-nodejs/docker-compose.logs) | -- |
Expand Down
7 changes: 7 additions & 0 deletions participantes/LeGustaLagosta/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# entrega no rinha de backend

- nome: estêvão ruas
- tecnologias:
- go (com gin e gorm)
- postgresql
- nginx
97 changes: 97 additions & 0 deletions participantes/LeGustaLagosta/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version: "3.5"

services:
api01: &api
# Lembre-se de que seu serviço HTTP deve estar hospedado num repositório
# publicamente acessível! Ex.: hub.docker.com
image: legustalagosta/rinha-api:no-gin
hostname: api01
environment:
- DB_HOSTNAME=db
- DB_PORT=5432
- DB_DATABASE=rinha
- DB_USER=admin
- DB_PASSWORD=123

# Não é necessário expor qualquer porta além da porta do load balancer,
# mas é comum as pessoas o fazerem para testarem suas APIs e conectarem
# ao banco de dados na fase de desenvolvimento.
ports:
- "8081:8080"
depends_on:
db:
condition: service_healthy
deploy:
resources:
limits:
cpus: "0.35"
memory: "60MB"

api02:
# Essa sintaxe reusa o que foi declarado em 'api01'.
<<: *api
hostname: api02
environment:
- DB_HOSTNAME=db
- DB_PORT=5432
- DB_DATABASE=rinha
- DB_USER=admin
- DB_PASSWORD=123
ports:
- "8082:8080"

nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api01
- api02
ports:
# Obrigatório expor/usar a porta 9999 no load balancer!
- "9999:9999"
deploy:
resources:
limits:
cpus: "0.25"
memory: "60MB"

db:
image: postgres:latest
hostname: db
environment:
- POSTGRES_PASSWORD=123
- POSTGRES_USER=admin
- POSTGRES_DB=rinha
ports:
- "5432:5432"
restart: always
healthcheck:
test: "pg_isready -U admin -d rinha"
interval: 5s
timeout: 5s
retries: 5
volumes:
- ./sql/script.sql:/docker-entrypoint-initdb.d/script.sql
- ./postgresql.conf:/etc/postgresql/postgresql.conf:ro
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
deploy:
resources:
limits:
# Note que a soma de todos os limites dos serviços
# aqui declarados é de 1.5 unidades de CPU e 550MB
# de memória. A distribuição feita aqui é apenas
# um exemplo – distribua como quiser.
cpus: "0.55"
memory: "370MB"

# O uso do modo `bridge` deve ser adequado à carga que será usada no teste.
# A edição anterior se beneficiou do modo host pois o volume de requisições
# era relativamente alto e a virtualização da rede se tornou um gargalo, mas
# este modo é mais complexo de ser configurado. Fique à vontade para usar o
# modo que quiser desde que não conflite com portas trivialmente usadas em um
# SO.
networks:
default:
driver: bridge
name: rinha-nginx-2024q1
64 changes: 64 additions & 0 deletions participantes/LeGustaLagosta/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
worker_processes auto;
worker_rlimit_nofile 32768;
# worker_rlimit_nofile 20000;

events {
worker_connections 16384; # Adjusted to fit within memory constraint
# worker_connections 20000; # Adjusted to fit within memory constraint
multi_accept on; # Enable multiple accept calls to handle more connections efficiently
use epoll; # Use epoll event notification mechanism for better performance on Linux
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 5; # Reduced to reclaim connections faster

# Buffer sizes reduced to fit within memory constraint
# client_body_buffer_size 4k;
# client_max_body_size 10m;
# client_header_buffer_size 1k;
# large_client_header_buffers 2 1k;
client_body_buffer_size 2k;
client_max_body_size 2k;
client_header_buffer_size 1k;
large_client_header_buffers 2 1k;

# Disable logging or set to a minimal level
access_log off; # Turn off access logging to save resources
# error_log /var/log/nginx/error.log crit; # Set error log level to 'crit' for critical errors only

# Gzip compression disabled due to memory constraint
gzip off;

# Load balancing configuration for API servers
upstream api {
server api01:8080;
server api02:8080;
keepalive 500;
}

server {
listen 9999; # Lembra da porta 9999 obrigatória?

location / {
proxy_pass http://api;
proxy_http_version 1.1;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Connection "";
# proxy_set_header Keep-Alive "";
# proxy_set_header Proxy-Connection "keep-alive";

# Buffer requests and responses above a certain size
proxy_buffering on;
proxy_buffer_size 12k; # Buffer size for proxied request or response
proxy_buffers 4 8k; # Number and size of buffers for proxied request or response
# proxy_buffering off;
}
}
}
37 changes: 37 additions & 0 deletions participantes/LeGustaLagosta/postgresql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# General Settings
listen_addresses = '*' # Listen on all interfaces
max_connections = 1024 # Maximum concurrent connections (adjust according to your system's capacity)
shared_buffers = 32MB # Amount of memory used for caching data (reduced to fit within memory constraint)
work_mem = 8MB # Amount of memory used for internal sort operations
maintenance_work_mem = 64MB # Amount of memory used for maintenance tasks like VACUUM, CREATE INDEX
# wal_level = minimal # Set WAL level to 'minimal' for reduced write overhead
wal_level = replica # Set WAL level to 'replica' for replication support
synchronous_commit = off # Asynchronous commit for better performance
checkpoint_timeout = 5min # Interval between automatic WAL checkpoints (reduced for more frequent checkpoints)
checkpoint_completion_target = 0.7 # Target duration for completing checkpoints

# Autovacuum Settings
autovacuum = on # Enable autovacuum
autovacuum_max_workers = 2 # Maximum number of autovacuum worker processes
autovacuum_naptime = 1min # Time between autovacuum runs
autovacuum_vacuum_scale_factor = 0.05 # Threshold to trigger a VACUUM
autovacuum_analyze_scale_factor = 0.02 # Threshold to trigger an ANALYZE

# Logging
# log_statement = 'all' # Log all SQL statements
# log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' # Customize log line format
# log_min_duration_statement = 200 # Log SQL statements longer than 200ms

# Logging
log_statement = 'none' # Disable logging of SQL statements to save resources
log_connections = off # Turn off logging of successful connections
log_disconnections = off # Turn off logging of disconnections

# Connection Settings
tcp_keepalives_idle = 60 # TCP keepalives idle time
tcp_keepalives_interval = 5 # TCP keepalives interval
tcp_keepalives_count = 5 # TCP keepalives count

# Other Settings
effective_cache_size = 100MB # Estimate of how much memory is available for caching data (reduced to fit within memory constraint)
random_page_cost = 2.0 # Relative cost of a non-sequentially fetched disk page compared to a page fetched sequentially
22 changes: 22 additions & 0 deletions participantes/LeGustaLagosta/sql/script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
create table clientes (
id serial primary key,
limite integer,
saldo integer
);

create table transacoes (
id serial primary key,
valor integer,
tipo varchar(1),
descricao varchar(20),
data_transacao timestamp,
id_cliente integer references clientes(id)
);

create index on transacoes (id_cliente);

insert into clientes (limite, saldo) values (100000, 0);
insert into clientes (limite, saldo) values (80000, 0);
insert into clientes (limite, saldo) values (1000000, 0);
insert into clientes (limite, saldo) values (10000000, 0);
insert into clientes (limite, saldo) values (500000, 0);
22 changes: 22 additions & 0 deletions participantes/adrianog3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Submissão para Rinha de Backend, Segunda Edição: 2024/Q1 - Controle de Concorrência

<div style="display: flex; align-items: center; gap: 12px">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/3/30/Java_programming_language_logo.svg/800px-Java_programming_language_logo.svg.png" alt="logo java" width="50" height="auto">
<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" alt="logo postgres" width="50" height="auto">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Nginx_logo.svg" alt="logo nginx" width="100" height="auto">
<br />
</div>

## Adriano Souza Arruda

Submissão feita com:

- `nginx` como load balancer
- `postgres` como banco de dados
- `java` para api com os frameworks `quarkus` e `hibernate`
- [repositório da api](https://github.com/adrianog3/rinha-backend-2024-q1-java)


### Contato
- [adrianog3](https://www.linkedin.com/in/adrianog3/) - linkedin
- [@adriano_g5](https://twitter.com/adriano_g5) - twitter
Loading

0 comments on commit 02e053f

Please sign in to comment.