• 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

Prioritize user request

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Firstly, I'm sorry if I posted to a wrong place as I don't where it should fit.
My question is if I have a web resource, says a JSP page, and I'd like to give priority to certain user to access the page.
i.e. paid user will have faster access than anonymous user
How can I achieve it?
I've read an article on this sometime back but couldn't recall anymore.
I'd appreciate anyone can advice how this is achieved and also, if this is under "Load balancing", "Request filtering", or .....
Thanks for any advice.
Cheers.

Han Ming
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about setting the priority of the thread executing the request:

Bill
 
Author
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Original question:

My question is if I have a web resource, says a JSP page, and I'd like to give priority to certain user to access the page.
i.e. paid user will have faster access than anonymous user
How can I achieve it?


Suggested solution:


How about setting the priority of the thread executing the request:


Well, it is hard to know what the original user wanted, but I'm not so sure this thread-priority idea will work very well.
First of all, my general rule of thumb for multithreaded programming is "Don't use thread priorities to control execution speed." That's because the Thread spec is deliberately vague about scheduling algorithms (to allow for OS-specific optimizations). In practice, many schedulers do NOT follow the practice that all OS's follow for user priorities, namely that all threads make SOME progress. Many just run higher-priority threads in lieu of lower-priority ones, except when the higher-priority ones are waiting on I/O. So, increasing a thread's priority could result in it taking over the whole server. Decreasing it could prevent it from ever running at all. Of course, I'm being paranoid here since there is lots of I/O going on. Still, on a heavily-loaded server, this could be a problem: the unpaying customers might NEVER run.
Second, what if the load is light? The original user didn't say, but I got the impression that unpaid users should still run slowly. With Thread priorities, they'd run just as fast when NO higher-priority threads were around.
Third, in many apps, the only thing that really matters is how long the database call takes. So, slowing down or speeding up the main thread wouldn't make any difference if the database call takes the same amount of time.
So, if that behavior is really what you want, maybe just do a few small Thread.sleep calls in the unpaid user's response? A Filter could apply this behavior universally without putting that logic in each page separately.
Cheers-
- Marty
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic