• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Request prioritization

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic