Skip to content

Commit

Permalink
Merge pull request #8 from abdelaziz-mahdy/spring-boot
Browse files Browse the repository at this point in the history
Spring boot
  • Loading branch information
abdelaziz-mahdy committed Jun 1, 2024
2 parents 615fde6 + e6d8e87 commit 16bf0b9
Show file tree
Hide file tree
Showing 38 changed files with 3,211 additions and 21 deletions.
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,69 +55,75 @@ Visual comparisons for database endpoints and static endpoints are provided to s
# Database Endpoints

## Comparison Graph with db endpoints
![Comparison Graph](comparison_graph_db_test.png?v=1717056948)
![Comparison Graph](comparison_graph_db_test.png?v=1717266655)

## Detailed Graphs for each backend
- **go mux db_test**
![go mux db_test Benchmark Graph](backends/go/mux/tests/results/db_test/graph.png?v=1717056948)
![go mux db_test Benchmark Graph](backends/go/mux/tests/results/db_test/graph.png?v=1717266655)

- **c_sharp dot net db_test**
![c_sharp dot net db_test Benchmark Graph](backends/c_sharp/dot-net/tests/results/db_test/graph.png?v=1717056948)
![c_sharp dot net db_test Benchmark Graph](backends/c_sharp/dot-net/tests/results/db_test/graph.png?v=1717266655)

- **python django sync db_test**
![python django sync db_test Benchmark Graph](backends/python/django-sync/tests/results/db_test/graph.png?v=1717056948)
![python django sync db_test Benchmark Graph](backends/python/django-sync/tests/results/db_test/graph.png?v=1717266655)

- **python fast api db_test**
![python fast api db_test Benchmark Graph](backends/python/fast-api/tests/results/db_test/graph.png?v=1717056948)
![python fast api db_test Benchmark Graph](backends/python/fast-api/tests/results/db_test/graph.png?v=1717266655)

- **python django async db_test**
![python django async db_test Benchmark Graph](backends/python/django-async/tests/results/db_test/graph.png?v=1717056948)
![python django async db_test Benchmark Graph](backends/python/django-async/tests/results/db_test/graph.png?v=1717266655)

- **dart server pod db_test**
![dart server pod db_test Benchmark Graph](backends/dart/server-pod/tests/results/db_test/graph.png?v=1717056948)
![dart server pod db_test Benchmark Graph](backends/dart/server-pod/tests/results/db_test/graph.png?v=1717266655)

- **rust actix web db_test**
![rust actix web db_test Benchmark Graph](backends/rust/actix-web/tests/results/db_test/graph.png?v=1717056948)
![rust actix web db_test Benchmark Graph](backends/rust/actix-web/tests/results/db_test/graph.png?v=1717266655)

- **java spring boot db_test**
![java spring boot db_test Benchmark Graph](backends/java/spring-boot/tests/results/db_test/graph.png?v=1717266655)

- **javascript express bun db_test**
![javascript express bun db_test Benchmark Graph](backends/javascript/express-bun/tests/results/db_test/graph.png?v=1717056948)
![javascript express bun db_test Benchmark Graph](backends/javascript/express-bun/tests/results/db_test/graph.png?v=1717266655)

- **javascript express node db_test**
![javascript express node db_test Benchmark Graph](backends/javascript/express-node/tests/results/db_test/graph.png?v=1717056948)
![javascript express node db_test Benchmark Graph](backends/javascript/express-node/tests/results/db_test/graph.png?v=1717266655)



# Static Endpoints

## Comparison Graph with static endpoints
![Comparison Graph](comparison_graph_no_db_test.png?v=1717056948)
![Comparison Graph](comparison_graph_no_db_test.png?v=1717266655)

## Detailed Graphs for each backend
- **go mux no_db_test**
![go mux no_db_test Benchmark Graph](backends/go/mux/tests/results/no_db_test/graph.png?v=1717056948)
![go mux no_db_test Benchmark Graph](backends/go/mux/tests/results/no_db_test/graph.png?v=1717266655)

- **c_sharp dot net no_db_test**
![c_sharp dot net no_db_test Benchmark Graph](backends/c_sharp/dot-net/tests/results/no_db_test/graph.png?v=1717056948)
![c_sharp dot net no_db_test Benchmark Graph](backends/c_sharp/dot-net/tests/results/no_db_test/graph.png?v=1717266655)

- **python django sync no_db_test**
![python django sync no_db_test Benchmark Graph](backends/python/django-sync/tests/results/no_db_test/graph.png?v=1717056948)
![python django sync no_db_test Benchmark Graph](backends/python/django-sync/tests/results/no_db_test/graph.png?v=1717266655)

- **python fast api no_db_test**
![python fast api no_db_test Benchmark Graph](backends/python/fast-api/tests/results/no_db_test/graph.png?v=1717056948)
![python fast api no_db_test Benchmark Graph](backends/python/fast-api/tests/results/no_db_test/graph.png?v=1717266655)

- **python django async no_db_test**
![python django async no_db_test Benchmark Graph](backends/python/django-async/tests/results/no_db_test/graph.png?v=1717056948)
![python django async no_db_test Benchmark Graph](backends/python/django-async/tests/results/no_db_test/graph.png?v=1717266655)

- **dart server pod no_db_test**
![dart server pod no_db_test Benchmark Graph](backends/dart/server-pod/tests/results/no_db_test/graph.png?v=1717056948)
![dart server pod no_db_test Benchmark Graph](backends/dart/server-pod/tests/results/no_db_test/graph.png?v=1717266655)

- **rust actix web no_db_test**
![rust actix web no_db_test Benchmark Graph](backends/rust/actix-web/tests/results/no_db_test/graph.png?v=1717056948)
![rust actix web no_db_test Benchmark Graph](backends/rust/actix-web/tests/results/no_db_test/graph.png?v=1717266655)

- **java spring boot no_db_test**
![java spring boot no_db_test Benchmark Graph](backends/java/spring-boot/tests/results/no_db_test/graph.png?v=1717266655)

- **javascript express bun no_db_test**
![javascript express bun no_db_test Benchmark Graph](backends/javascript/express-bun/tests/results/no_db_test/graph.png?v=1717056948)
![javascript express bun no_db_test Benchmark Graph](backends/javascript/express-bun/tests/results/no_db_test/graph.png?v=1717266655)

- **javascript express node no_db_test**
![javascript express node no_db_test Benchmark Graph](backends/javascript/express-node/tests/results/no_db_test/graph.png?v=1717056948)
![javascript express node no_db_test Benchmark Graph](backends/javascript/express-node/tests/results/no_db_test/graph.png?v=1717266655)


95 changes: 95 additions & 0 deletions backends/java/spring-boot/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
services:
db:
image: postgres:16.1
restart: always
# volumes:
# # - ./data/db:/var/lib/postgresql/data
# # - ./pg_hba.conf:/var/lib/foo/pg_hba.conf
# command: postgres -c hba_file=/var/lib/foo/pg_hba.conf
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

# pgbouncer:
# image: edoburu/pgbouncer
# environment:
# - DB_USER=postgres
# - DB_PASSWORD=postgres
# - DB_HOST=db
# # - DB_NAME=test
# - POOL_MODE=transaction
# - ADMIN_USERS=postgres,dbuser
# - AUTH_TYPE=scram-sha-256
# - MAX_CLIENT_CONN=100000
# # ports:
# # - "5432:5432"
# depends_on:
# - db
# healthcheck:
# test: "pg_isready --host localhost -U postgres"
# interval: 5s
# timeout: 5s
# retries: 5
benchmark:
restart: always
build:
context: ./server
dockerfile: ./Dockerfile

ports:
- "${PORT:-8080}:8080"

environment:
- DATABASE_NAME=postgres
- DATABASE_USER=postgres
- DATABASE_PASSWORD=postgres
- DATABASE_HOST=db
- DATABASE_PORT=5432
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8080/"
start_period: 30s
interval: 15s
timeout: 10s
retries: 10
depends_on:
# pgbouncer:
# condition: service_healthy
db:
condition: service_healthy
tester:
image: locustio/locust
volumes:
- ./tests:/mnt/locust
- ./tests/results/${test_type}:/home/locust/
command: >
-f /mnt/locust/${test_type}.py
--csv benchmark
--run-time ${LOCUST_RUNTIME}
--headless
--users ${LOCUST_USERS}
--spawn-rate ${LOCUST_SPAWN_RATE}
-H http://benchmark:8080
${LOCUST_ARGS}
--master
# ports:
# - 8089:8089
depends_on:
benchmark:
condition: service_healthy
tester_worker:
image: locustio/locust
volumes:
- ./tests:/mnt/locust
- ./tests/results/${test_type}:/home/locust/
command: >
-f /mnt/locust/${test_type}.py
--worker --master-host tester
depends_on:
benchmark:
condition: service_healthy
47 changes: 47 additions & 0 deletions backends/java/spring-boot/docker_build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
cd "${0%/*}"

# Build and start services for Django-Python
# cd benchmark
# bash update_requirements.sh
# cd ..

#!/bin/bash

# Save the current directory
dir=$(pwd)

# Flag to check if the script is found
found=0

# Loop through the current and parent directories
while true; do
# Check if the script exists in the current directory
if [[ -f "$dir/internal_scripts/set_required_envs.sh" ]]; then
# Script found, execute it
echo "Found script at $dir/internal_scripts/set_required_envs.sh"
. "$dir/internal_scripts/set_required_envs.sh"

found=1
break
else
# Move to the parent directory
parentdir=$(dirname "$dir")
# Check if we have reached the root directory
if [[ "$dir" == "$parentdir" ]]; then
break
fi
dir=$parentdir
fi
done

# Check if script was not found
if [[ $found -eq 0 ]]; then
echo "Script not found."
exit 1
fi

. "$dir/internal_scripts/set_test_type.sh"

# Rest of the script...
. "$dir/internal_scripts/record_usages.sh"
40 changes: 40 additions & 0 deletions backends/java/spring-boot/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Use the official Maven image to build the app
FROM maven:3.8.1-openjdk-17 AS build

# Set the working directory
WORKDIR /app

# Copy the pom.xml and download dependencies
COPY pom.xml .
RUN mvn dependency:go-offline -B

# Copy the source code
COPY src ./src

# Package the application
RUN mvn package -DskipTests

# Use the official OpenJDK image to run the app
FROM openjdk:17-jdk-slim

# Install curl
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the packaged jar file from the build stage
COPY --from=build /app/target/demo-0.0.1-SNAPSHOT.jar app.jar

# Set environment variables for PostgreSQL connection
ENV DATABASE_HOST=localhost
ENV DATABASE_PORT=5432
ENV DATABASE_NAME=mydatabase
ENV DATABASE_USER=myuser
ENV DATABASE_PASSWORD=mypassword

# Expose the port the app runs on
EXPOSE 8080

# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]
19 changes: 19 additions & 0 deletions backends/java/spring-boot/server/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.3.0/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.3.0/maven-plugin/reference/html/#build-image)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#web)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data)

### Guides
The following guides illustrate how to use some features concretely:

* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)

Loading

0 comments on commit 16bf0b9

Please sign in to comment.