Skip to content

Commit a3c62e4

Browse files
gautamg795Convex, Inc.
authored andcommitted
add rate limiting to the instance loader (#39902)
GitOrigin-RevId: 222aa9cbe0d3f8cf6c38685a8c3b18d6575d9451
1 parent 51901c0 commit a3c62e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/common/src/knobs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,21 @@ pub static COMMIT_TRACE_THRESHOLD: LazyLock<Duration> =
13301330
pub static INSTANCE_LOADER_CONCURRENCY: LazyLock<usize> =
13311331
LazyLock::new(|| env_config("INSTANCE_LOADER_CONCURRENCY", 16));
13321332

1333+
/// Whether or not to use a rate limiter when loading instances
1334+
pub static INSTANCE_LOADER_USE_RATE_LIMITER: LazyLock<bool> =
1335+
LazyLock::new(|| env_config("INSTANCE_LOADER_USE_RATE_LIMITER", true));
1336+
1337+
/// The number of instances that can be loaded per second when the rate limiter
1338+
/// is in use. The default value of 4 means that for a Conductor with 5000
1339+
/// instances, we'd take about 20 minutes to load all instances with infinite
1340+
/// concurrency.
1341+
pub static INSTANCE_LOADER_INSTANCES_PER_SECOND: LazyLock<NonZeroU32> = LazyLock::new(|| {
1342+
env_config(
1343+
"INSTANCE_LOADER_INSTANCES_PER_SECOND",
1344+
NonZeroU32::new(4).unwrap(),
1345+
)
1346+
});
1347+
13331348
/// The max number of storage files that can be fetched concurrently during
13341349
/// export. Concurrency is also limited by `EXPORT_MAX_INFLIGHT_PREFETCH_BYTES`.
13351350
pub static EXPORT_STORAGE_GET_CONCURRENCY: LazyLock<usize> =

0 commit comments

Comments
 (0)