Skip to content

Commit

Permalink
fix(awc_client): increase payload size to 1mb default and 4mb in config
Browse files Browse the repository at this point in the history
  • Loading branch information
bassco committed Nov 15, 2023
1 parent 43e1009 commit 61b68e7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
25 changes: 23 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
3 changes: 2 additions & 1 deletion config/compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
12 changes: 10 additions & 2 deletions scripts/dali-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"

Expand Down Expand Up @@ -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
}

Expand Down
13 changes: 10 additions & 3 deletions scripts/dali-tests-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/commons/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("\"", "\\\"");
Expand Down

0 comments on commit 61b68e7

Please sign in to comment.