Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

How to process 1000 request using Thread

Thread view: 
niraj - 21 Mar 2007 19:26 GMT
I have one problem. What is the optimal approach for handling 1000
request by using thread.there are 2 scenario. 1 create 1000 thread and
execute the program 2. create 10 thread and pool 1000 requests by some
scheduling algorithm.
Eric Sosman - 21 Mar 2007 19:51 GMT
> I have one problem. What is the optimal approach for handling 1000
> request by using thread.there are 2 scenario. 1 create 1000 thread and
> execute the program 2. create 10 thread and pool 1000 requests by some
> scheduling algorithm.

    Too many variables, not enough detail.  What is the nature
of these "requests," how much processing power does each need,
what kind of throughput and/or latency requirements exist, how
many CPUs are available, how much memory (relative to the amount
needed to process a request) is available, ...?

    That said, a thousand threads is certainly far out in the
fringe of unreasonability: they will chew up "a lot" of memory
in thread stacks and other structures, they will spend "a lot"
of time performing context switches, and so on.  But you have
not provided enough information for me to recommend using ten
threads, or a hundred, or one.  The only thing I can suggest is
that you decouple the thread count from the request count, so
you can adjust the former to suit the resources of the machine
of the moment rather than letting the request count govern your
life.

Signature

Eric Sosman
esosman@acm-dot-org.invalid

Oliver Wong - 22 Mar 2007 23:07 GMT
>> I have one problem. What is the optimal approach for handling 1000
>> request by using thread.there are 2 scenario. 1 create 1000 thread and
[quoted text clipped - 11 lines]
> in thread stacks and other structures, they will spend "a lot"
> of time performing context switches, and so on.

   Unless perhaps they're using a 1024 core CPU?
http://www.technologyreview.com/read_article.aspx?id=17076&ch=infotech

   - Oliver
RedGrittyBrick - 21 Mar 2007 23:18 GMT
> I have one problem. What is the optimal approach for handling 1000
> request by using thread.there are 2 scenario. 1 create 1000 thread and
> execute the program 2. create 10 thread and pool 1000 requests by some
> scheduling algorithm.

My guess is that of those two alternatives the second is likely to be
closer to optimal.

I imagine a more optimal solution would be a design that starts with n
threads (where n is some tunable parameter that can be selected at
program launch time). To further optimise it (if needed) I'd have some
mechanism for dropping threads that are unused for a long period and for
starting new threads when the pool becomes busy.

The above is all superficial guesswork. It shouldn't be too hard to
benchmark all three through.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.