-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7a669d
commit 359bda3
Showing
5 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM ubuntu:latest as BUILD | ||
|
||
# Install Oracle OpenJDK 21 | ||
RUN apt -y update && apt -y upgrade && apt -y install wget | ||
RUN wget https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz | ||
RUN tar zxvf openjdk-21_linux-x64_bin.tar.gz | ||
ENV JAVA_HOME=/jdk-21 | ||
ENV PATH="$JAVA_HOME/bin:${PATH}" | ||
|
||
WORKDIR /app | ||
|
||
COPY src /app/src | ||
COPY pom.xml /app | ||
COPY .mvn /app/.mvn | ||
COPY mvnw /app/mvnw | ||
|
||
RUN ./mvnw clean package -DskipTests | ||
|
||
FROM ubuntu:latest as RUNTIME | ||
|
||
COPY --from=BUILD /app/target/rinhabackend2023-0.0.1-SNAPSHOT.jar /rinha.jar | ||
COPY --from=BUILD /jdk-21 /jdk-21 | ||
|
||
ENV JAVA_HOME=/jdk-21 | ||
ENV PATH="$JAVA_HOME/bin:${PATH}" | ||
|
||
EXPOSE 8080 | ||
|
||
|
||
ENTRYPOINT [ "java", "-XX:+UseParallelGC", "-XX:MaxRAMPercentage=75", "--enable-preview", "-jar", "./rinha.jar" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
version: '3.9' | ||
|
||
# 1.5 CPUs = 0.70 MongoDB + 2 x 0.35 Spring Boot + 0.05 Redis + 0.05 NGinx | ||
# 3.0 GB = 0.65 MongoDB + 2 x 1.10 Spring Boot + 0.05 Redis + 0.10 NGinx | ||
|
||
services: | ||
spring-api1: | ||
image: boaglio/rinhabackend2023:latest | ||
hostname: spring-api1 | ||
environment: | ||
- SERVER_PORT=8080 | ||
- MONGO_URI=mongodb://db-mongodb:27017/rinhadb?socketTimeoutMS=360000&connectTimeoutMS=360000&maxPoolSize=50&minPoolSize=50 | ||
- REDIS_HOST=cache | ||
depends_on: | ||
- db-mongodb | ||
- cache | ||
ulimits: | ||
nofile: | ||
soft: 1000000 | ||
hard: 1000000 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '0.35' | ||
memory: '1.1GB' | ||
networks: | ||
- app-network | ||
|
||
spring-api2: | ||
image: boaglio/rinhabackend2023:latest | ||
hostname: spring-api2 | ||
environment: | ||
- SERVER_PORT=8080 | ||
- MONGO_URI=mongodb://db-mongodb:27017/rinhadb?socketTimeoutMS=360000&connectTimeoutMS=360000&maxPoolSize=50&minPoolSize=50 | ||
- REDIS_HOST=cache | ||
depends_on: | ||
- db-mongodb | ||
- cache | ||
ulimits: | ||
nofile: | ||
soft: 1000000 | ||
hard: 1000000 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '0.35' | ||
memory: '1.1GB' | ||
networks: | ||
- app-network | ||
|
||
nginx: | ||
image: nginx:latest | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf:ro | ||
depends_on: | ||
- spring-api1 | ||
- spring-api2 | ||
ports: | ||
- "9999:9999" | ||
networks: | ||
- app-network | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '0.05' | ||
memory: '0.1GB' | ||
|
||
cache: | ||
hostname: cache | ||
image: redis:latest | ||
command: ["redis-server", "--appendonly", "no", "--save ''"] | ||
ports: | ||
- '6379:6379' | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '0.05' | ||
memory: '0.05GB' | ||
networks: | ||
- app-network | ||
|
||
db-mongodb: | ||
image: mongo:latest | ||
ports: | ||
- "27017:27017" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: '0.7' | ||
memory: '0.65GB' | ||
networks: | ||
- app-network | ||
|
||
networks: | ||
app-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
events { | ||
worker_connections 10000; | ||
} | ||
http { | ||
access_log off; | ||
error_log off; | ||
|
||
upstream api { | ||
server spring-api1:8080; | ||
server spring-api2:8080; | ||
} | ||
|
||
server { | ||
listen 9999; | ||
|
||
location / { | ||
proxy_pass http://api; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/bash | ||
|
||
# docker system prune -f | ||
|
||
GATLING_BIN_DIR=$HOME/gatling/bin | ||
GATLING_WORKSPACE=$HOME/rinha-de-backend-2023-q3/stress-test | ||
RESULTS_WORKSPACE=$HOME/rinha-de-backend-2023-q3/resultados/final | ||
|
||
finalistas=("ss" "ss") | ||
|
||
for finalista in ${finalistas[@]}; do | ||
( | ||
diretorio="participantes/$finalista/" | ||
echo "======================" | ||
echo $finalista | ||
|
||
if test -f "$RESULTS_WORKSPACE/$finalista/testado"; then | ||
echo "$finalista já testado - ignorando." | ||
else | ||
cd $diretorio | ||
echo "iniciando e logando execução da API" | ||
mkdir "$RESULTS_WORKSPACE/$finalista" | ||
docker-compose up -d --build | ||
docker-compose logs > "$RESULTS_WORKSPACE/$finalista/docker-compose.logs" | ||
echo "pausa de 15 segundos para startup pra API" | ||
sleep 15 | ||
echo "iniciando teste" | ||
sh $GATLING_BIN_DIR/gatling.sh -rm local -s RinhaBackendSimulation \ | ||
-rd $finalista \ | ||
-rf "$RESULTS_WORKSPACE/$finalista" \ | ||
-sf $GATLING_WORKSPACE/user-files/simulations \ | ||
-rsf $GATLING_WORKSPACE/user-files/resources | ||
echo "teste finalizado" | ||
echo "fazendo request e salvando a contagem de pessoas" | ||
curl -v "http://localhost:9999/contagem-pessoas" > "$RESULTS_WORKSPACE/$finalista/contagem-pessoas.log" | ||
echo "cleaning up do docker" | ||
docker-compose rm -f | ||
docker-compose down | ||
touch "$RESULTS_WORKSPACE/$finalista/testado" | ||
fi | ||
) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters