aspose file tools
The moose likes JSP and the fly likes Prioritize user request Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Prioritize user request" Watch "Prioritize user request" New topic
Author

Prioritize user request

HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
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
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 11862
How about setting the priority of the thread executing the request:

Bill


Java Resources at www.wbrogden.com
Marty Hall
Author
Ranch Hand

Joined: Jan 02, 2003
Posts: 111
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


Java training and consulting<br /><a href="http://www.coreservlets.com/" target="_blank" rel="nofollow">http://www.coreservlets.com/</a>
 
 
subject: Prioritize user request
 
Threads others viewed
JSF Request Processing Lifecycle Basics
very urgent idea needed
Preventing direct access to a redirected page
Keeping the user acegi retrieved
request.getAttribute returning null.
IntelliJ Java IDE