This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request prioritization

 
Aditi Gandy
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can any one tell me how to prioritize the requests in service method?
Assuming that there are thousands of requests coming to the servlet at the same time, how to prioritize which request to be considered first?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not control over the threading behaviour of the servlet container so there isn't much you can do. Sounds like an odd requirement though, why do you need to prioritize one specific client?
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Paul mentions it is indeed a strange requirement.
But then if you *really* need to implement something like that you can probably queue up the requests in a synchronised list, and have an independent thread scan this list and pick up requests to service based upon some 'priority' parameter value.

On the flipside, like you mentioned there may be thousands of requests - I really won't suggest using a data-structure to queue up the requests [you never know when your JVM runs out of memory]. Also, I'm pretty sure that the end user [client] experience won't be that great. Especially so, when the server makes him/her wait for a response for no apparent reason [assuming they aren't aware of the prioritisation of requests scenario]
 
Aditi Gandy
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Anirvan and Paul.

Thanks a lot.

This was asked in one of the interviews. I really didn't know the answer.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While it's an unusual requirement, I don't think it's all that odd. There may be contractual QoS stipulations that offer higher priority for some clients (who would presumably have to pay for the privilege).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic