`object_store` puts a 30-second `reqwest` timeout on the whole request, body included. On a proxied blob that is not a timeout at all: the bucket is read at the pace the client drains it, so it is a maximum servable file size. The reason it never looked like one is that object_store hides its own consequences. It catches every response-body error and silently retries with a resumed Range, so a large read does not fail at 30s -- it reconnects every 30s and keeps going, until RetryConfig's 180s retry_timeout is spent. Then the body simply ends, with a 200 already on the wire and nothing logged anywhere. The ceiling is 180s x bandwidth: at the 8MB/s a GPU host gets to caveman, no file over ~1.4GB can ever be served, and no client retry converges because the next attempt is no faster. Measured against the live bucket, 500MiB at 1MB/s: cut at 184.1s, 193,340,351 of 524,288,000 bytes. With the timeout disabled, 499.6s and complete -- the same wall time curl takes reading the same object straight from MinIO. Disable it, and guard the stream the way a stream should be guarded: `storage.connect_timeout` and an idle `storage.read_timeout` that bounds silence rather than progress. A test asserts the total cap stays off. Issue #1 named `server.request_timeout` as the cause. It was not -- that key was parsed and then read by nothing, which is its own problem and is why the hunt started 300 seconds away from a 180-second bug. Remove it. Also log when a blob response ends before its Content-Length. Once the headers are out the bytes leave through hyper, so a cut mid-body was invisible on this side: the service logged a clean 200 while the client saw a short read and retried forever. Refs #1 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PqNtYNhov3fukx46KS9R7L
61 lines
2.3 KiB
Rust
61 lines
2.3 KiB
Rust
//! Prometheus metrics.
|
|
//!
|
|
//! Label sets are deliberately small. A metric keyed on repo id would give a
|
|
//! registry serving a few hundred models a few hundred time series per
|
|
//! counter, which is a cost paid forever for a question the manifests already
|
|
//! answer.
|
|
|
|
use metrics::{counter, gauge, histogram};
|
|
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
|
|
use rustingface_core::Source;
|
|
use rustingface_entities::error::{Error, Result};
|
|
|
|
/// Install the recorder and return the handle `/metrics` renders from.
|
|
pub fn install() -> Result<PrometheusHandle> {
|
|
PrometheusBuilder::new()
|
|
.set_buckets(&[0.005, 0.025, 0.1, 0.5, 1.0, 5.0, 30.0, 120.0, 600.0, 3600.0])
|
|
.map_err(|e| Error::Config(format!("metrics buckets: {e}")))?
|
|
.install_recorder()
|
|
.map_err(|e| Error::Config(format!("metrics recorder: {e}")))
|
|
}
|
|
|
|
/// Record a completed request.
|
|
pub fn request(route: &'static str, status: u16) {
|
|
counter!("rustingface_requests_total", "route" => route, "status" => status.to_string())
|
|
.increment(1);
|
|
}
|
|
|
|
/// Record where a served body came from.
|
|
pub fn served(source: Source, bytes: u64) {
|
|
let label = match source {
|
|
Source::Bucket => "bucket",
|
|
Source::Upstream => "upstream",
|
|
};
|
|
counter!("rustingface_bytes_served_total", "source" => label).increment(bytes);
|
|
}
|
|
|
|
/// Record a blob response that ended before its `Content-Length`.
|
|
///
|
|
/// The bytes leave through hyper rather than through a handler that can return
|
|
/// a status, so a cut mid-body is otherwise invisible on this side: the client
|
|
/// retries forever and the service logs a clean 200.
|
|
pub fn truncated(source: Source, bytes: u64) {
|
|
let label = match source {
|
|
Source::Bucket => "bucket",
|
|
Source::Upstream => "upstream",
|
|
};
|
|
counter!("rustingface_blob_truncations_total", "source" => label).increment(1);
|
|
counter!("rustingface_bytes_truncated_total", "source" => label).increment(bytes);
|
|
}
|
|
|
|
/// Record the outcome of an upstream fetch.
|
|
pub fn upstream_fetch(result: &'static str, seconds: f64) {
|
|
counter!("rustingface_upstream_fetches_total", "result" => result).increment(1);
|
|
histogram!("rustingface_upstream_fetch_seconds").record(seconds);
|
|
}
|
|
|
|
/// Publish how many fetches are in flight.
|
|
pub fn in_flight(count: usize) {
|
|
gauge!("rustingface_fetches_in_flight").set(count as f64);
|
|
}
|