• Post Reply Bookmark Topic Watch Topic
  • New Topic

*** Which one do you think is BETTER ??? ***

 
Ramalingam Vijayakumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Assume that I have a Server ....
also assume that 100 clients are connecting to the server
Is it efficent when i spawn a different procees to manage every client....
(OR)
is it efficent to create a seperate thread to manage 100 clients.

which one do you feel is correct,manageable and efficent one.
thanx in advance ,
bye
ram...
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Threads have efficient and easy access to shared resources; they are also created much faster (although you still might want to plump for a thread pool). Unless your server has outlandish requirements, threads are the way to go.
- Peter
 
Ramalingam Vijayakumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello peter.
Thanx a lot for your reply...
In your answer do you mean that my server should be dedicated only to that process which is having 100 threads...
I also have onbe doubt ...if I have 100 threads in a process how is the CPU scheduling being done..
Thanx alot...
bye,
ram.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramalingam Vijayakumar:
In your answer do you mean that my server should be dedicated only to that process which is having 100 threads...

Not necessarily. 100 threads won't bring a decent server to its knees.
I also have onbe doubt ...if I have 100 threads in a process how is the CPU scheduling being done..

The general answer is: "unspecified". The Java language specification does not prescribe any threading implementation. Having said that, these days you can generally expect time-sliced pre-emptive threading. The precise implementation would depend on the operating system (on a Linux kernel, your server would look quite spectacular in "top").
- Peter
 
Ramalingam Vijayakumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello peter,
Thanx a lot for your reply...
I have got one more doubt..
will my OS know that there are threads inside a process ??
thanx in advance..
bye
ram.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramalingam Vijayakumar:
Hi all,
Assume that I have a Server ....
also assume that 100 clients are connecting to the server
Is it efficent when i spawn a different procees to manage every client....
(OR)
is it efficent to create a seperate thread to manage 100 clients.

which one do you feel is correct,manageable and efficent one.
thanx in advance ,
bye
ram...

Threads are lighter and will spawn faster. But they will all crash together. I would say you should use a thread pool, and only spawn around as many threads as you have processors to run them, make any other calls wait. A few more or less threads is OK. You just have to understand how much processor time you are able to acquire.
 
Jim Baiter
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run into a hard limit on Solaris of 1024 threads per process. But by using a thread pool of 1000 as someone mentioned, I could support far more "concurrent" users. For the communications problem of thread per socket, I think the NIO is addressing that issue.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Baiter:
I've run into a hard limit on Solaris of 1024 threads per process. But by using a thread pool of 1000 as someone mentioned, I could support far more "concurrent" users. For the communications problem of thread per socket, I think the NIO is addressing that issue.

"concurrent" would depend on how many "concurrent" processors you have. In a more virtual sense, 2 threads running on 1 processor where each thread gets an equal timeslice can make to the end user a 1GHz processor appear to be 500MHz (gross exaggeration and generalization). In any event, keep adding new threads and you keep dividing up the power. So now you have 1000 users all running on the equivalent of a 1MHz processor. Not a pretty site.
This is fair since all threads in this usage will be active and none will be wait() or sleep(). I am guessing that is how your implementation is. But you see what I am saying here right? Best to let some requests wait for the benefit of the speed of all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!