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

Monitor how many UDP requests are aborted when the maximum number of concurrent requests is reached #830

Closed
josecelano opened this issue May 3, 2024 · 0 comments · Fixed by #841
Labels
- Admin - Enjoyable to Install and Setup our Software Enhancement / Feature Request Something New Needs Feedback What dose the Community Think? Optimization Make it Faster

Comments

@josecelano
Copy link
Member

We handle a maximum of 50 UDP requests at the same time. When we have more than 50, we overwrite the latest one, and we give a second chance to the finish.

struct ActiveRequests {
    rb: StaticRb<AbortHandle, 50>, // the number of requests we handle at the same time.
}

// ...

async fn run_udp_server(tracker: Arc<Tracker>, socket: Arc<UdpSocket>) {
    let tracker = tracker.clone();
    let socket = socket.clone();

    let reqs = &mut ActiveRequests::default();

    // Main Waiting Loop, awaits on async [`receive_request`].
    loop {
        if let Some(h) = reqs.rb.push_overwrite(
            Self::spawn_request_processor(Self::receive_request(socket.clone()).await, tracker.clone(), socket.clone())
                .abort_handle(),
        ) {
            if !h.is_finished() {
                // the task is still running, lets yield and give it a chance to flush.
                tokio::task::yield_now().await;
                h.abort();
            }
        }
    }
}

The demo server has been busy recently and I'm curious how many UDP requests we are discarding (not even replying).

By the way @da2ce7 we are using the push_overwrite method.

image

That method overwrites the latest item, not the oldest. Does that make sense in our case? Would not be better if we overwrite the oldest request? That's the one that has had a longer time to be processed.

I'm planning to add a log (warning) before the h.abort() just to track the number of requests that are not processed. Then I can parse the logs to get the data like this.

@josecelano josecelano added Enhancement / Feature Request Something New - Admin - Enjoyable to Install and Setup our Software Optimization Make it Faster labels May 3, 2024
@josecelano josecelano changed the title Monitor how many UDP request we abort Monitor how many UDP requests we abort May 3, 2024
@josecelano josecelano added the Needs Feedback What dose the Community Think? label May 7, 2024
@josecelano josecelano linked a pull request May 7, 2024 that will close this issue
@josecelano josecelano changed the title Monitor how many UDP requests we abort Monitor how many UDP requests are aborted when the maximum number of concurrent requests is reached May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Admin - Enjoyable to Install and Setup our Software Enhancement / Feature Request Something New Needs Feedback What dose the Community Think? Optimization Make it Faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant