Skip to content

Commit

Permalink
fix hanging bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEDIUM-Off committed Jun 25, 2024
2 parents 519e58b + 4b4f8f7 commit 9bc1610
Show file tree
Hide file tree
Showing 33 changed files with 7,382 additions and 392 deletions.
2 changes: 1 addition & 1 deletion DockerfileDevEnv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM debian:bullseye-slim
RUN apt-get update
RUN apt-get install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh && bash nodesource_setup.sh
RUN apt-get install -y make clang python3 php-cgi libpthread-stubs0-dev nodejs
RUN apt-get install -y make clang python3 php-cgi libpthread-stubs0-dev nodejs valgrind

RUN mkdir -p /var/www/html

Expand Down
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# By: agaley <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/15 15:51:13 by agaley #+# #+# #
# Updated: 2024/06/21 16:36:27 by agaley ### ########lyon.fr #
# Updated: 2024/06/25 00:40:40 by agaley ### ########lyon.fr #
# #
# **************************************************************************** #

NAME = webserv

CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -MMD -std=c++98
DEBUGFLAGS = -g3 -fsanitize=address
DEBUGFLAGS = -g3

SRC_DIR = src
OBJ_DIR = obj
Expand All @@ -30,9 +30,9 @@ export NGINX_PORT_1 ?= 8000
export NGINX_PORT_2 ?= 8001

SRC = $(SRC_DIR)/Server.cpp \
$(SRC_DIR)/ConfigManager.cpp $(SRC_DIR)/ConfigParser.cpp \
$(SRC_DIR)/Config.cpp $(SRC_DIR)/ConfigManager.cpp $(SRC_DIR)/ConfigParser.cpp \
$(SRC_DIR)/FileManager.cpp \
$(SRC_DIR)/ConnectionHandler.cpp \
$(SRC_DIR)/ConnectionHandler.cpp $(SRC_DIR)/CacheHandler.cpp \
$(SRC_DIR)/Worker.cpp \
$(SRC_DIR)/HTTPRequest.cpp $(SRC_DIR)/HTTPResponse.cpp $(SRC_DIR)/URI.cpp \
$(SRC_DIR)/CGIHandler.cpp $(SRC_DIR)/FileHandler.cpp \
Expand All @@ -59,14 +59,17 @@ $(OBJ_DIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@

debug: $(DEBUG_OBJ)
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(DEBUG_OBJ) -o $(NAME)
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(DEBUG_OBJ) -lpthread -o $(NAME)

$(DEBUG_OBJ_DIR)/%.o: %.cpp
@mkdir -p $(DEBUG_OBJ_DIR)
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) -c $< -o $@

run: daemon
$(MAKE) wait-for-healthy
docker compose exec -it webserv make
docker compose exec -it webserv bash -c "kill 1"
sleep 1
@make logs

daemon:
Expand All @@ -78,13 +81,18 @@ watch:
inotifywait -qre close_write /app/src; \
done


dev:
export BUILD_TYPE=debug
docker compose up --build -d webserv-dev
docker compose exec -it webserv-dev make debug
docker compose exec -it webserv-dev bash -c "./webserv"

valgrind:
export BUILD_TYPE=debug
docker compose up --build -d webserv-dev
docker compose exec -it webserv-dev make debug
docker compose exec -it webserv-dev bash -c "ulimit -n 1024 && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./webserv"

logs:
docker compose logs -f

Expand Down
34 changes: 34 additions & 0 deletions NXtest_conf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
server {
listen 8080;
server_name test.local;

root /var/www/YoupiBanane;
index index.html;
# cgi on;

location / {
# autoindex on;
limit_except GET { deny all; }
}

location /put_test/ {
limit_except PUT { deny all; }
}

# location ~ \.bla$ {
# limit_except POST { deny all; }
# include /etc/nginx/fastcgi_params;
# fastcgi_pass unix:/var/run/cgi_test.sock;
# }

location /post_body {
limit_except POST { deny all; }
client_max_body_size 100;
}

location /directory/ {
limit_except GET { deny all; }
autoindex on;
index youpi.bad_extension;
}
}
74 changes: 74 additions & 0 deletions benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
no loadbalancing:
Lifting the server siege...
Transactions: 106412 hits
Availability: 100.00 %
Elapsed time: 29.09 secs
Data transferred: 70.53 MB
Response time: 0.01 secs
Transaction rate: 3658.03 trans/sec
Throughput: 2.42 MB/sec
Concurrency: 24.81
Successful transactions: 106413
Failed transactions: 0
Longest transaction: 0.03
Shortest transaction: 0.00


with loadbalancing (algo 1)
Lifting the server siege...
Transactions: 143922 hits
Availability: 100.00 %
Elapsed time: 29.32 secs
Data transferred: 95.39 MB
Response time: 0.01 secs
Transaction rate: 4908.66 trans/sec
Throughput: 3.25 MB/sec
Concurrency: 24.69
Successful transactions: 143922
Failed transactions: 0
Longest transaction: 0.05
Shortest transaction: 0.00

with loadbalancing (algo 2)
Lifting the server siege...
Transactions: 231742 hits
Availability: 100.00 %
Elapsed time: 29.67 secs
Data transferred: 153.60 MB
Response time: 0.00 secs
Transaction rate: 7810.65 trans/sec
Throughput: 5.18 MB/sec
Concurrency: 24.77
Successful transactions: 231742
Failed transactions: 0
Longest transaction: 0.06
Shortest transaction: 0.00
--------------------------------------
Lifting the server siege...
Transactions: 111982 hits
Availability: 100.00 %
Elapsed time: 17.79 secs
Data transferred: 74.22 MB
Response time: 0.00 secs
Transaction rate: 6294.66 trans/sec
Throughput: 4.17 MB/sec
Concurrency: 24.57
Successful transactions: 111983
Failed transactions: 0
Longest transaction: 0.03
Shortest transaction: 0.00

nginx:
Lifting the server siege...
Transactions: 458431 hits
Availability: 100.00 %
Elapsed time: 26.94 secs
Data transferred: 303.85 MB
Response time: 0.00 secs
Transaction rate: 17016.74 trans/sec
Throughput: 11.28 MB/sec
Concurrency: 22.63
Successful transactions: 458437
Failed transactions: 0
Longest transaction: 0.09
Shortest transaction: 0.00
16 changes: 16 additions & 0 deletions check_workers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Liste des IDs des workers qui ont démarré
started_workers = [
1209762, 1209771, 1209764, 1209770, 1209766, 1209769, 1209767, 1209765,
1209772, 1209768, 1209763, 1209773, 1209774, 1209775, 1209776, 1209777,
1209778, 1209779, 1209780, 1209781
]

# Liste des IDs des workers qui ont terminé
finished_workers = [
1209772, 1209771, 1209764, 1209777, 1209769, 1209767, 1209762, 1209765,
1209766, 1209781, 1209773, 1209776, 1209779, 1209763, 1209774, 1209780,
1209775, 1209778, 1209770
]
not_finished_workers = set(started_workers) - set(finished_workers)

print("Workers qui n'ont pas terminé:", not_finished_workers)
1 change: 1 addition & 0 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ server {
}

location /cgi/ {
autoindex on;
cgi on;
limit_except GET POST { deny all; }
}
Expand Down
79 changes: 79 additions & 0 deletions local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# NGINX Compatible conf (no cgi or upload)
worker_processes auto;

server {
listen 8080;
server_name example.co example.fr;

# Default error pages
# error_page 403 /errors/403.html;
# error_page 500 /errors/500.html;
error_page 404 /errors/404_main.html;

# Client body size limit (in bytes)
client_max_body_size 1048576; # 1MB

# root /var/www/html; # Root directory for the server
; root /home/mchenava/webserv/site;
root /mnt/e/webserv/site;
autoindex on;
# index index.html;

# Routes configuration
location / {
autoindex on;
index i-index.html; # Default file if request is a directory
limit_except GET POST { deny all; } # Allowed HTTP methods
client_max_body_size 123;
}

location /dir/ {
error_page 404 /errors/404_api.html;
limit_except GET POST { deny all; } # Allowed HTTP methods
}

location /site/ {
limit_except GET POST { deny all; } # Allowed HTTP methods
}

# location /upload/ {
# limit_except POST { deny all; } # Allowed HTTP methods
# accept_upload on;
# }

location /cgi/ {
cgi on;
limit_except GET POST { deny all; } # Allowed HTTP methods
}

location /cgi/off/ {
cgi off;
limit_except GET POST { deny all; } # Allowed HTTP methods
}

location /redirect/ {
return 301 http://anotherdomain.com;
return 200 blabla; # Should be ignored
limit_except GET { deny all; } # Allowed HTTP methods
}
}

# Additional server instance (example of multiple server configurations)
server {
listen 8081;
server_name another.local;

# Default error pages
error_page 404 /errors/404.html;
error_page 500 /errors/500.html;

# Client body size limit (in bytes)
client_max_body_size 2048000; # 2MB

location /files/ {
root /var/www/files;
index index.html;
limit_except GET POST { deny all; }
autoindex off;
}
}
Loading

0 comments on commit 9bc1610

Please sign in to comment.