From 6e461639ef175362245d620a521f3016f3d40c2c Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Wed, 15 Nov 2023 01:03:31 +0100 Subject: [PATCH] fix(awc_client): increase payload size to 1mb default an 4mb in config --- Cargo.toml | 25 +++++++++++++++++++++++-- config/compose.json | 3 ++- config/default.json | 3 ++- config/production.json | 3 ++- scripts/dali-bench.sh | 12 ++++++++++-- scripts/dali-tests-runner.sh | 13 ++++++++++--- src/commons/http.rs | 2 +- 7 files changed, 50 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a52b08d..5de81d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,10 @@ serde_qs = {version = "0.12.0", features=["actix4"]} config = "0.13.3" hyper = { version = "0.14.27", features=["full"], optional = true } hyper-timeout = { version = "0.4.1", optional = true } -libvips = "1.6.1" +# or use a git path or remote repo and branch +# libvips = {git = "file:///absolute/path/to/git/repo", rev = "12345"} +libvips = {git = "https://github.com/olxgroup-oss/libvips-rust-bindings.git", branch = "make-error-messages-explicit"} +# libvips = "1.5.0" rexif = "0.7.3" lazy_static = "1.4.0" cfg-if = "1.0.0" @@ -67,9 +70,27 @@ debug = 2 debug = 1 opt-level = 0 codegen-units = 8 -incremental = false +incremental = true [profile.release] incremental = true debug = 0 # Set this to 1 or 2 to get more useful backtraces in debugger. opt-level = 3 # Optimize for size + +[profile.awc] +inherits = "test" +# Disabling debug info speeds up builds a bunch, +# and we don't rely on it for debugging that much. +debug = 1 +opt-level = 0 +codegen-units = 8 +incremental = true + + +[[bin]] +name = "dali" +path = "src/main.rs" +[[bin]] +name = "dali_awc" +#filename = "dali_awc" +path = "src/main.rs" diff --git a/config/compose.json b/config/compose.json index efbf2f8..e9fab1d 100644 --- a/config/compose.json +++ b/config/compose.json @@ -7,5 +7,6 @@ "server_keep_alive": 1000, "http_client_con_timeout": 1000, "http_client_read_timeout": 1000, - "http_client_write_timeout": 1000 + "http_client_write_timeout": 1000, + "http_client_max_size_of_payload": 4096 } diff --git a/config/default.json b/config/default.json index f9b4122..efffa28 100644 --- a/config/default.json +++ b/config/default.json @@ -7,5 +7,6 @@ "server_keep_alive": 1000, "http_client_con_timeout": 1000, "http_client_read_timeout": 1000, - "http_client_write_timeout": 1000 + "http_client_write_timeout": 1000, + "http_client_max_size_of_payload": 4096 } diff --git a/config/production.json b/config/production.json index f9b4122..efffa28 100644 --- a/config/production.json +++ b/config/production.json @@ -7,5 +7,6 @@ "server_keep_alive": 1000, "http_client_con_timeout": 1000, "http_client_read_timeout": 1000, - "http_client_write_timeout": 1000 + "http_client_write_timeout": 1000, + "http_client_max_size_of_payload": 4096 } diff --git a/scripts/dali-bench.sh b/scripts/dali-bench.sh index 77231fb..599ed09 100755 --- a/scripts/dali-bench.sh +++ b/scripts/dali-bench.sh @@ -6,6 +6,14 @@ benchmark="${1:?"Please specify which benchmark file you want to test"}" features="${2:-hyper_client}" +binary="dali" +binary_extra="" +if [ "${features}" == "awc_client" ];then + binary_extra="_awc" +fi + +binary="${binary}${binary_extra}" + # We can run the server with different features to test different server implementations # current the is hyper_client, the default, and awc_client # we need cargo-criterion crate installed so that we can compare the @@ -30,7 +38,7 @@ run_benchmark() { echo "Running benchmark $benchmark using the feature:$features" sleep 5 - HTTP_HOST=localhost:8080 RUN_MODE=default cargo run --features "${features}" >> /dev/null & + HTTP_HOST=localhost:8080 RUN_MODE=default cargo run --features "${features}" --bin "${binary}">> /dev/null & PID=$! echo "Dali:[$features] is running on PID($PID)" @@ -60,7 +68,7 @@ stop_process() { setup() { # docker: -p outside:inside - docker run --rm -v ./tests/resources/:/usr/share/nginx/html/ -p 9000:80 --name dali-http-nginx-source -d nginx:1.23.3-alpine-slim + docker run --rm -v ./tests/resources/:/usr/share/nginx/html/ -p 9000:80 --name dali-http-nginx-source -d nginx:1.25.3-alpine-slim wait_until_ready localhost 9000 } diff --git a/scripts/dali-tests-runner.sh b/scripts/dali-tests-runner.sh index 0c41747..d34f4ed 100755 --- a/scripts/dali-tests-runner.sh +++ b/scripts/dali-tests-runner.sh @@ -2,12 +2,19 @@ # requires docker service to be running features="${1:-hyper_client}" +binary="dali" +binary_extra="" +if [ "${features}" == "awc_client" ];then + binary_extra="_awc" +fi + +binary="${binary}${binary_extra}" run_tests() { - HTTP_HOST=localhost:9000 RUN_MODE=default cargo run --features "${features}" >> /dev/null & + HTTP_HOST=localhost:9000 RUN_MODE=default cargo run --bin ${binary} --features "${features}" >> /dev/null & PID=$! wait_until_ready localhost 8080 - HTTP_HOST=localhost:9000 cargo test --features "${features}" + HTTP_HOST=localhost:9000 cargo test --bin ${binary} --features "${features}" RCODE=$? stop_process ${PID} localhost 8080 } @@ -30,7 +37,7 @@ stop_process() { } setup() { - docker run --rm -v ./tests/resources/:/usr/share/nginx/html/ -p 9000:80 --name dali-http-nginx-source -d nginx:1.23.3-alpine-slim + docker run --rm -v ./tests/resources/:/usr/share/nginx/html/ -p 9000:80 --name dali-http-nginx-source -d nginx:1.25.3-alpine-slim wait_until_ready localhost 9000 } diff --git a/src/commons/http.rs b/src/commons/http.rs index 1f7b7c3..9978c69 100644 --- a/src/commons/http.rs +++ b/src/commons/http.rs @@ -121,7 +121,7 @@ pub mod client { response .body() // https://docs.rs/awc/2.0.0-alpha.1/awc/struct.MessageBody.html#method.limit - .limit(config.http_client_max_size_of_payload.unwrap_or(256 * 1024) as usize) + .limit(config.http_client_max_size_of_payload.unwrap_or(1024 * 1024) as usize) .await .map_err(move |e| { let error_str = format!("{}", e).replace("\"", "\\\"");