Reputation: 5827
I have an app that needs to send 2000 http get requests per second but when I do that, the client app cannot get response after a while. When I check tcp ip ports, i see lots of tcp ip ports that is TIME WAIT state.
So 2000 reqs per second is too much for one server ? Is there any best practice to run an application like that ?
I tried to change the server configuration but it did not help too much. https://msdn.microsoft.com/en-us/library/aa560610(v=bts.20).aspx
I am running code below while testing the scenario above,
var client = new RestClient("http://localhost:5000/")
{
Proxy = null
};
var counter = 0;
while (true)
{
var request = new RestRequest("api/values", Method.GET) {Timeout = 5000};
client.ExecuteAsync(request, response =>
{
Console.WriteLine(response.StatusCode + "=> " + counter++);
});
}
Upvotes: 0
Views: 167
Reputation: 11909
The problem with HTTP is it's really designed for 1 query and 1 response (yes I know there are ways to keep the socket open).
A better solution to your problem, is to open 1 standard TCP/IP socket to the server and send multiple queries (and get responses) down this single socket.
2000 queries per second isn't that many these days, so any decent server hardware would be able to keep up, provided your code is efficient.
Upvotes: 1