Skip to content

linrium/quantile-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Calculate percentile

Run

git clone git@github.com:linrium/quantile-api.git
cd quantile-api
RUST_LOG=info cargo run --release

Changelogs

Update version 0.1.1

  • 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

Unit test

Pass 100% unit test cargo test

Coverage test

image Following this instruction https://github.com/mozilla/grcov#how-to-get-grcov

Load test

(Without caching) image

(With caching) image

(With Dashmap) image

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

API

Postman online document

https://documenter.getpostman.com/view/2939491/TzeTJV3d

Environments

POST /append

Endpoint: {{HOST}}/append

Body:

interface Body {
  poolId: number // required
  poolValues: number[] // required
}

Response:

interface Response {
  status: "inserted" | "appended"
}

Example:

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
]
}"

POST /query

Endpoint: {{HOST}}/query

Body:

interface Body {
  poolId: number // required
  percentile: number // required, gte 0, lte 100
}

Response success:

interface Response {
  quantile: number,
  count: number
}

Response error:

interface Response {
  code: number,
  message: string
}

Example:

curl --location --request POST "https://compute-quantile.onrender.com/query" \
--header "Content-Type: application/json" \
--data-raw "{
    \"poolId\": 1,
    \"percentile\": 50.6
}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages