What's the best way to create a accept limit for servers with tokio

HI.
I have adopted layer4-proxy from great Jacob :smiley:

Now I think to implement a "max concurrent clients".

A Internet search shows some examples with Thread pool or semaphores but it's not clear for me what's the best solution in production environment with 5,50 or even 10k concurrent clients.

Thanks for any feedback.

The recommendation is to use a semaphore. Please see the Limit the number of incoming requests being handled at the same time example.

1 Like

Thank you for your fast and reliable answer.

I have now tried to implement the semaphore but I'm not sure in which block I should add the drop.

I hope that anybody can give me a hint here, thank you.

The semaphore is defined here

and created here

Put the drop inside the tokio::spawn after the call to accept.

1 Like

:star_struck: Thank you soooom much. :bowing_man:

With this statement was I now able to create a connection limit which looks now like this.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.