Skip to content

Increase target shard usage #5771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion quickwit/quickwit-common/src/shared_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub const DEFAULT_SHARD_THROUGHPUT_LIMIT: ByteSize = ByteSize::mib(5);
pub const DEFAULT_SHARD_BURST_LIMIT: ByteSize = ByteSize::mib(50);

/// A compromise between "exponential" scale up and moderate shard count increase.
pub const DEFAULT_SHARD_SCALE_UP_FACTOR: f32 = 1.5;
pub const DEFAULT_SHARD_SCALE_UP_FACTOR: f32 = 1.1;

// (Just a reexport).
pub use bytesize::MIB;
56 changes: 49 additions & 7 deletions quickwit/quickwit-control-plane/src/ingest/scaling_arbiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl ScalingArbiter {
scale_up_shards_short_term_threshold_mib_per_sec: max_shard_throughput_mib_per_sec
* 0.8f32,
scale_up_shards_long_term_threshold_mib_per_sec: max_shard_throughput_mib_per_sec
* 0.3f32,
scale_down_shards_threshold_mib_per_sec: max_shard_throughput_mib_per_sec * 0.2f32,
* 0.375f32,
scale_down_shards_threshold_mib_per_sec: max_shard_throughput_mib_per_sec * 0.25f32,
shard_scale_up_factor,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increase the target load by 25% only. Increasing it more would prevent the scaling from 1 shard to 2 shards to happen properly. Take max_shard_throughput_mib_per_sec=5MB and num_open_shards=1:

  • with 0.3 as scale up load factor, scale_up_shards_long_term_threshold_mib_per_sec=1.5MB. This means that avg_long_term_ingestion_rate must be >3MB for scaling event to occur.
  • with 0.375 as scale up load factor, scale_up_shards_long_term_threshold_mib_per_sec=1.875MB. This means that avg_long_term_ingestion_rate must be >3.75MB for scaling event to occur.
  • with 0.45 as scale up load factor, scale_up_shards_long_term_threshold_mib_per_sec=2.25MB. This means that avg_long_term_ingestion_rate must be >4.5MB for scaling event to occur.

This is due to how long_term_scale_up_threshold_max_shards avoids getting into the interval [scale_down, scale_up]

}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ mod tests {
scaling_arbiter.should_scale(ShardStats {
num_open_shards: 1,
avg_short_term_ingestion_rate: 8.0,
avg_long_term_ingestion_rate: 3.1,
avg_long_term_ingestion_rate: 5.,
}),
None,
);
Expand All @@ -236,7 +236,7 @@ mod tests {
scaling_arbiter.should_scale(ShardStats {
num_open_shards: 2,
avg_short_term_ingestion_rate: 8.1,
avg_long_term_ingestion_rate: 5.,
avg_long_term_ingestion_rate: 6.,
}),
Some(ScalingMode::Up(1)),
);
Expand All @@ -246,7 +246,7 @@ mod tests {
fn test_scale_up_computations() {
// use shard throughput 10MiB to simplify calculations
let scaling_arbiter =
ScalingArbiter::with_max_shard_ingestion_throughput_mib_per_sec(10.0, 1.5);
ScalingArbiter::with_max_shard_ingestion_throughput_mib_per_sec(10.0, 1.1);

let shard_stats = ShardStats {
num_open_shards: 0,
Expand All @@ -267,6 +267,20 @@ mod tests {
avg_short_term_ingestion_rate: 5.0,
avg_long_term_ingestion_rate: 6.1,
};
assert_eq!(
scaling_arbiter.long_term_scale_up_threshold_max_shards(shard_stats),
1
);
assert_eq!(
scaling_arbiter.scale_up_factor_target_shards(shard_stats),
2
);

let shard_stats = ShardStats {
num_open_shards: 1,
avg_short_term_ingestion_rate: 5.0,
avg_long_term_ingestion_rate: 7.5,
};
assert_eq!(
scaling_arbiter.long_term_scale_up_threshold_max_shards(shard_stats),
2
Expand Down Expand Up @@ -297,7 +311,7 @@ mod tests {
};
assert_eq!(
scaling_arbiter.long_term_scale_up_threshold_max_shards(shard_stats),
4
3
);
assert_eq!(
scaling_arbiter.scale_up_factor_target_shards(shard_stats),
Expand All @@ -315,7 +329,35 @@ mod tests {
);
assert_eq!(
scaling_arbiter.scale_up_factor_target_shards(shard_stats),
8
6
);

let shard_stats = ShardStats {
num_open_shards: 20,
avg_short_term_ingestion_rate: 5.0,
avg_long_term_ingestion_rate: 1.1,
};
assert_eq!(
scaling_arbiter.long_term_scale_up_threshold_max_shards(shard_stats),
5
);
assert_eq!(
scaling_arbiter.scale_up_factor_target_shards(shard_stats),
22
);

let shard_stats = ShardStats {
num_open_shards: 40,
avg_short_term_ingestion_rate: 5.0,
avg_long_term_ingestion_rate: 1.1,
};
assert_eq!(
scaling_arbiter.long_term_scale_up_threshold_max_shards(shard_stats),
11
);
assert_eq!(
scaling_arbiter.scale_up_factor_target_shards(shard_stats),
44
);
}
}