Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is having a separate background task to clean up necessary? #29

Open
hristogochev opened this issue Apr 18, 2024 · 0 comments
Open

Is having a separate background task to clean up necessary? #29

hristogochev opened this issue Apr 18, 2024 · 0 comments

Comments

@hristogochev
Copy link

hristogochev commented Apr 18, 2024

Is having the code for cleaning up (that's specified in the official example) necessary for each configuration you create?
What is it actually doing?
Will the memory build up over time if you don't clean it manually using the background task or does it clean periodically even without the background task?
I'm talking about this code specifically:

let governor_limiter = governor_conf.limiter().clone();
let interval = Duration::from_secs(60);
// a separate background task to clean up
std::thread::spawn(move || {
    loop {
        std::thread::sleep(interval);
        tracing::info!("rate limiting storage size: {}", governor_limiter.len());
        governor_limiter.retain_recent();
    }
});

Wouldn't using a tokio task with tokio::spawn be more efficient if we are already using Axum for example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant