Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to process 1000 request using Thread

Reply
Thread Tools

How to process 1000 request using Thread

 
 
niraj
Guest
Posts: n/a
 
      03-21-2007
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.

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      03-21-2007
niraj wrote:
> 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.

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid
 
Reply With Quote
 
 
 
 
RedGrittyBrick
Guest
Posts: n/a
 
      03-21-2007
niraj wrote:
> 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.
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      03-22-2007

"Eric Sosman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed). ..
> niraj wrote:
>> 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.


Unless perhaps they're using a 1024 core CPU?
http://www.technologyreview.com/read...76&ch=infotech

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to process 1000 files xml to 1 file? AMDx64BT XML 2 03-08-2011 09:46 PM
Re: How to process 1000 files xml to 1 file? AMDx64BT XML 0 03-08-2011 07:25 AM
Optimizing the expression (x * 1000 / 1000) pozz C Programming 27 03-04-2011 04:46 AM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments