5 个不稳定版本
0.3.0 | 2021 年 12 月 31 日 |
---|---|
0.2.2 | 2021 年 5 月 23 日 |
0.2.1 | 2021 年 5 月 23 日 |
0.2.0 | 2021 年 5 月 22 日 |
0.1.0 | 2021 年 5 月 22 日 |
#359 在 可视化
27KB
341 行
usl
usl
是 Rust 模型器,用于 Dr. Neil Gunther 的 通用可扩展性定律,如 Baron Schwartz 的书籍 使用通用可扩展性定律进行实用可扩展性分析 中所述。
给定任意两个 Little's Law 参数(吞吐量、延迟和并发性)的一组测量值,USL 允许您根据任意参数的任意值预测这些参数值。例如,给定并发性和吞吐量的一组测量值,USL 将允许您预测在特定吞吐量下系统的平均延迟将是什么样子,或者您需要多少服务器来处理请求并保持您的服务级别协议的延迟要求。
模型系数和预测应与书中列出的值相差 0.001% 以内。
如何使用此工具
以一个例子来说明,假设要对 HTTP 服务器进行负载测试和容量规划。要使用 USL 对系统行为进行建模,您必须首先收集一组系统测量值。这些测量值必须是 Little's Law 的三个参数中的两个:平均响应时间(以秒为单位)、吞吐量(以每秒请求数为单位)和并发性(即并发客户端的数量)。
因为响应时间往往与负载(即随着吞吐量或并发性的增加而增加)有关,所以你的测试中的因变量应该是平均响应时间。这使吞吐量或并发性成为你的自变量,但多亏了Little's Law,你使用哪个都无关紧要。为了讨论的目的,假设你将吞吐量作为一个固定速率下的并发客户端数量的函数来衡量(例如,你使用了vegeta
)。
负载测试完成后,你应该有一组这样的测量结果
并发性 | 吞吐量 |
---|---|
1 | 65 |
18 | 996 |
36 | 1652 |
72 | 1853 |
108 | 1829 |
144 | 1775 |
216 | 1702 |
现在你可以构建一个模型并开始估计事物。
作为命令行工具
cargo install usl --features=cli
$ cat measurements.csv
1,65
18,996
36,1652
72,1853
etc.
usl --plot example.csv 10 50 100 150 200 250 300
USL parameters: σ=0.028168, κ=90.691376, λ=0.000104
max throughput: 1882.421555, max concurrency: 96
contention constrained
| ■ ● × ● ●
| ● ■ ■● × ●
| ■ × ● × ● ■
1600-| ●
|
t |
h |
r 1200-| ●
o |
u | ■
g |
h |
p 800-| ×
u |
t |
|
400-|
|
|
|
0+--------------------------------------------------------------------------------
| | | | | |
0 40 80 120 160 200
concurrency
10,718.1341832148264
50,1720.7701516725795
100,1881.977293350178
150,1808.2668068616638
200,1687.6636402563477
250,1564.4594617061496
300,1450.4659509826192
作为库
use usl::{Model, Measurement};
fn main() {
let measurements = vec![
Measurement::concurrency_and_throughput(1, 65.0),
Measurement::concurrency_and_throughput(18, 996.0),
Measurement::concurrency_and_throughput(36, 1652.0),
Measurement::concurrency_and_throughput(72, 1853.0),
Measurement::concurrency_and_throughput(108, 1829.0),
Measurement::concurrency_and_throughput(144, 1775.0),
Measurement::concurrency_and_throughput(216, 1702.0),
];
let model = Model::build(&measurements);
println!("{}", model.throughput_at_concurrency(100));
}
性能
构建模型非常快
build time: [9.4531 us 9.4605 us 9.4677 us]
进一步阅读
我强烈推荐《使用通用可扩展性定律进行实用可扩展性分析》,这是由Baron Schwartz撰写的一本免费电子书,他是《高性能MySQL》的作者,也是VividCortex的首席执行官。在不真正理解Little's Law、Amdahl's Law和通用可扩展性定律背后的概念的情况下尝试使用这个库将是困难的,并且可能具有误导性。
许可证
版权所有 © 2021 Coda Hale
Apache License 2.0或MIT许可证下分发。
依赖项
~0.2–1MB
~16K SLoC