Quick note: I created an issue in axum as well as this involves both tower and axum. I can close whichever of the two makes the most sense.
I am running into an issue with using the RateLimitLayer from tower with axum. I noticed that I can keep sending requests and the rate isn't actually limited. Below is a complete example.
[package]
name = "axum-rate-limit-test"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.7.4"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["std"] }
tokio = { version = "1.35.0", features = ["full"] }
tower = { version = "0.4.13", features = ["limit", "buffer"] }
Quick note: I created an issue in axum as well as this involves both tower and axum. I can close whichever of the two makes the most sense.
I am running into an issue with using the
RateLimitLayer
fromtower
withaxum
. I noticed that I can keep sending requests and the rate isn't actually limited. Below is a complete example.I expected the request rate to be limited to 1 per 5 seconds. But the below script executes without any rate limiting.