wcygan / load-generator

a cli-based network load generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add rate limiting

wcygan opened this issue · comments

Right now the load generator sends as much traffic as it can, as fast as it can, without a limit.

It might be desirable to a rate limiter to help soften the blow to a server so that it doesn't get absolutely swamped.

Rate limiting can be achieved with lib_wc::RateLimiter. Example usage of this is seen in the Web Crawler that I built using it.

let res = rate_limiter
        .throttle("https://en.wikipedia.org", || crawl(client, "https://en.wikipedia.org/wiki/Rust_(programming_language)"))
        .await;