Calculate percentile
git clone git@github.com:linrium/quantile-api.git
cd quantile-api
RUST_LOG=info cargo run --release
- Change f64 to f32 to improve memory usage
- Refactor common package (to errors and utils packages)
- Sort value in query service (remove sort in append service)
- Replace Mutex to Dashmap - fast concurrent hashmap share between threads (benchmark here)
- Update load test with Dashmap
Pass 100% unit test
cargo test
Following this instruction https://github.com/mozilla/grcov#how-to-get-grcov
Following this instruction https://github.com/alexfernandez/loadtest Example:
loadtest -n 100000 -c 100 -m POST -T 'application/json' --data '{"poolId": 1, "percentile": 50}' http://localhost:3000/query
https://documenter.getpostman.com/view/2939491/TzeTJV3d
- HOST: localhost:3000 or (deployed version https://compute-quantile.onrender.com)
interface Body {
poolId: number // required
poolValues: number[] // required
}
interface Response {
status: "inserted" | "appended"
}
curl --location --request POST "localhost:3000/append" \
--header "Content-Type: application/json" \
--data-raw "{
\"poolId\": 1,
\"poolValues\": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
]
}"
interface Body {
poolId: number // required
percentile: number // required, gte 0, lte 100
}
interface Response {
quantile: number,
count: number
}
interface Response {
code: number,
message: string
}
curl --location --request POST "https://compute-quantile.onrender.com/query" \
--header "Content-Type: application/json" \
--data-raw "{
\"poolId\": 1,
\"percentile\": 50.6
}"