问题描述:

I want to send the same http request repeatedly unless I get the right response, and the server is slow, sending the request is quick, receiving the response is quick also, but waiting for server to handle the request is slow. So if I send the request, and then waiting the failure should not be acceptable.

I think of the following workflow:

1)Sending the request

2)After sending the data, start a new request to send the same request

repeat 1-2, and the response should be handled asynchronously, and when detecting the right response, it stop sending request.

How to achieve this workflow or any other workflow can solve my problem. Any language and tool which will be fast would be considerable, like C/C++.

网友答案:

This will cause the server to simply respond slower and slower; your first request will be the first to receive any response, all the others will be wasted CPU time and bandwidth - if you did that to my servers you'd get your IP banned automatically.

What you need to consider is

  • why do you need the response this fast?
  • can you cache the response so that re-requesting it is no longer needed
  • perhaps having a caching proxy between your client(s) and the server will cover your needs? (also, prefetching)
相关阅读:
Top