Skip to content

Commit 8ef0d14

Browse files
committed
try using rustls feature in addition to rustls-tls, connection pool 20, and add throughput logging
Signed-off-by: technillogue <[email protected]>
1 parent be52ebd commit 8ef0d14

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

storage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ leaky-bucket = { version = "0.12.1", optional = true }
2323
libc = "0.2"
2424
log = "0.4.8"
2525
nix = "0.24"
26-
reqwest = { version = "0.11.14", features = ["blocking", "json"], optional = true }
26+
reqwest = { version = "0.11.14", features = ["blocking", "json", "rustls", "rustls-tls"], optional = true }
2727
serde = { version = "1.0.110", features = ["serde_derive", "rc"] }
2828
serde_json = "1.0.53"
2929
sha1 = { version = "0.10.5", optional = true }

storage/src/backend/connection.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,9 @@ impl Connection {
631631
.timeout(timeout)
632632
.connect_timeout(connect_timeout)
633633
.redirect(Policy::none());
634+
.use_rustls_tls()
635+
.tcp_keepalive(Some(Duration::from_secs(5 * 60)))
636+
.pool_max_idle_per_host(20);
634637

635638
if config.skip_verify {
636639
cb = cb.danger_accept_invalid_certs(true);
@@ -639,7 +642,11 @@ impl Connection {
639642
if !proxy.is_empty() {
640643
cb = cb.proxy(reqwest::Proxy::all(proxy).map_err(|e| einval!(e))?)
641644
}
642-
645+
debug!(
646+
"{} building connection with proxy: {}",
647+
std::thread::current().name().unwrap_or_default(),
648+
proxy
649+
);
643650
cb.build().map_err(|e| einval!(e))
644651
}
645652

storage/src/cache/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,17 @@ pub trait BlobCache: Send + Sync {
270270
)));
271271
}
272272
let duration = Instant::now().duration_since(start).as_millis();
273+
let duration_s = duration as f64 / 1000.0;
274+
let throughput_mbps = blob_size as f64 / duration_s / 1_000_000.0;
275+
273276
debug!(
274-
"read_chunks_from_backend: {} {} {} bytes at {}, duration {}ms",
277+
"read_chunks_from_backend: {} {} {} bytes at {}, duration {}ms, throughput {:.4}Mbps",
275278
std::thread::current().name().unwrap_or_default(),
276279
if prefetch { "prefetch" } else { "fetch" },
277280
blob_size,
278281
blob_offset,
279-
duration
282+
duration,
283+
throughput_mbps
280284
);
281285

282286
let chunks = chunks.iter().map(|v| v.as_ref()).collect();
@@ -328,12 +332,15 @@ pub trait BlobCache: Send + Sync {
328332
}
329333

330334
let duration = Instant::now().duration_since(start).as_millis();
335+
let duration_s = duration as f64 / 1000.0;
336+
let throughput_mbps = blob_size as f64 / duration_s / 1_000_000.0;
331337
debug!(
332-
"read_chunk_from_backend: {} {} bytes at {}, duration {}ms",
338+
"read_chunk_from_backend: {} {} bytes at {}, duration {}ms, throughput {:.4}Mbps",
333339
std::thread::current().name().unwrap_or_default(),
334340
chunk.compressed_size(),
335341
chunk.compressed_offset(),
336-
duration
342+
duration,
343+
throughput_mbps
337344
);
338345
self.validate_chunk_data(chunk, buffer, false)
339346
.map_err(|e| {

0 commit comments

Comments
 (0)