2021年1月20日星期三

How to prioritize a certain request in java?

I feel like this is such a niche question so I will try to explain it as best possible as I can.

Intro: I'm sending ~500 requests / second and I feel like the more requests I send the slower the requests are handled (it becomes noticeably slower at some point)

Question: So the question is in Java is there any way to prioritize a request? Any solution that I am seeking is to optimize the speed of such request.. So any answer that would take time before the request is sent is not of my concern.

INFO: (I hope this is sufficient if not please tell me!)

  • The library I am using is apache httpclients (however I can switch if the solutions calls for it)
  • I also am multi threading the requests on one server/pc. I hope this is helpful information.
  • CPU Usage varies from (5-15%) - I believe these are the measurements enter image description here

I am sending 2 types of request and I only need to prioritize 1 type

  1. HTTP GET Request - HTML Response expected
  2. HTTP POST Request - JSON response expected (although I do not need the response)

#2 is the request that I want to prioritize. I send this request very little but when I send it I need it to be as quick as possible.

Solutions thought of: The only solution I have come up with is to stop/end all of the live connections in order to execute the request I want, however I think that doing so will take a considerable amount of time causing the solution to become a waste of time.

Note: You could say I am an idiot in this area so if the solution is non existent or obvious I am sorry, also if there is a duplicate I am also sorry.. I could not find any questions even close to this.

https://stackoverflow.com/questions/65820285/how-to-prioritize-a-certain-request-in-java January 21, 2021 at 10:15AM

没有评论:

发表评论