Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1323473
graph: Add MovingStats to track duration statistics over a moving window
lutter Jun 26, 2020
6f309c4
graph, graphql: Move shape_hash into graph crate
lutter Jun 26, 2020
38e21b3
graph, graphql: Store the shape_hash in our Query structs
lutter Jun 26, 2020
01cf897
graph: Add a facility for tracking query effort
lutter Jun 26, 2020
b1cc6c7
all: Have GraphQlRunner manage effort tracking
lutter Jun 26, 2020
fd63d88
graph, graphql: Configure window and bin sizes for stats through envi…
lutter Jun 26, 2020
a14587a
all: Track wait stats in connection pool, add LoadManager
lutter Jun 27, 2020
642ac19
all: Move blocking of expensive queries into the LoadManager
lutter Jun 27, 2020
f336570
graph: Decline to run queries when load exceeds a threshold
lutter Jun 27, 2020
697b89a
all: Use a HashSet to store banned/jailed queries in the LoadManager
lutter Jun 28, 2020
e864b3c
graph: Log information about LoadManager decisions
lutter Jun 29, 2020
5f52a9b
graph: Log queries that the LoadManager puts in jail
lutter Jun 29, 2020
80d916e
all: Make LoadManager and argument to GraphQlRunner::new
lutter Jun 29, 2020
c76f20c
graphql: Use a query's hash and shape_hash as the query_id for timing…
lutter Jun 29, 2020
63fafd1
store: Revamp how we log connection checkout wait times
lutter Jun 29, 2020
7ee08cc
store: Report average connection wait times to Prometheus
lutter Jul 1, 2020
6281e1e
all: Report moving average of total query time to Prometheus
lutter Jul 1, 2020
8ccfa9a
graph: Fix logic of what to log in LoadManager
lutter Jul 2, 2020
5d7d046
graph: Clamp LoadManager's kill_rate and probability to drop query
lutter Jul 2, 2020
75ef747
all: Address review comments for load management
lutter Jul 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,16 @@ those.
Due to implementation details, this value may not be strictly adhered to. Defaults to 10.
- `GRAPH_LOG_POI_EVENTS`: Logs Proof of Indexing events deterministically.
This may be useful for debugging.
- `GRAPH_LOAD_WINDOW_SIZE`, `GRAPH_LOAD_BIN_SIZE`: Load can be
automatically throttled if load measurements over a time period of
`GRAPH_LOAD_WINDOW_SIZE` seconds exceed a threshold. Measurements within
each window are binned into bins of `GRAPH_LOAD_BIN_SIZE` seconds. The
variables default to 300s and 1s
- `GRAPH_LOAD_THRESHOLD`: If wait times for getting database connections go
above this threshold, throttle queries until the wait times fall below
the threshold. Value is in milliseconds, and defaults to 0 which
turns throttling off and any associated statistics collection off.
- `GRAPH_LOAD_JAIL_THRESHOLD`: When the system is overloaded, any query
that causes more than this fraction of the effort will be rejected for as
long as the process is running (i.e., even after the overload situation
is resolved) Defaults to 0.1
4 changes: 4 additions & 0 deletions graph/src/components/graphql.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use futures::prelude::*;

use crate::data::graphql::effort::LoadManager;
use crate::data::query::{Query, QueryError, QueryResult};
use crate::data::subscription::{Subscription, SubscriptionError, SubscriptionResult};

Expand All @@ -8,6 +9,7 @@ use failure::format_err;
use failure::Error;
use futures03::compat::Future01CompatExt;
use graphql_parser::query as q;
use std::sync::Arc;

/// Future for query results.
pub type QueryResultFuture = Box<dyn Future<Item = QueryResult, Error = QueryError> + Send>;
Expand Down Expand Up @@ -47,4 +49,6 @@ pub trait GraphQlRunner: Send + Sync + 'static {
}
})
}

fn load_manager(&self) -> Arc<LoadManager>;
}
6 changes: 5 additions & 1 deletion graph/src/components/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::env;
use std::fmt;
use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::sync::{Arc, RwLock};
use std::time::{Duration, Instant};
use web3::types::{Address, H256};

Expand Down Expand Up @@ -1214,6 +1214,10 @@ mock! {
}
}

// The type that the connection pool uses to track wait times for
// connection checkouts
pub type PoolWaitStats = Arc<RwLock<MovingStats>>;

// The store trait must be implemented manually because mockall does not support async_trait, nor borrowing from arguments.
impl Store for MockStore {
fn block_ptr(
Expand Down
Loading