Re: Millions of Threads ?
Arne Vajh?j wrote:
frankgerlach@gmail.com wrote:
Well, a quick calculation suggests that a single server (4CPU or so)
could handle a million clients: Say each client sends 10 messages of
1000 bytes per day (The application in question is not very
data-intensive). That's 1000000*10*1000==10Gbyte. An internet
connection with 10Mbyte/sec (100Mbit Ethernet) could easily handle
this: 10000000*86400=864Gbyte. (Assuming there are no significant
traffic spikes). If I used Gbit Ethernet I could scale even higher; and
then I drop in 4 to 10 Gbit Ethernet cards...
If we assume that you spend 20 milliseconds processing
a request then a roundtrip over all connections
if they all need to process with 4 CPU's will take 83 minutes.
I hope it is not an interactive application.
:-)
Arne
If each client sends 10 messages a day, there is a relatively low
probability that they all need service simultaneously. On the other
hand, it would be equally unreasonable to assume the traffic is
uniformly distributed.
I would model message arrivals with a Poisson distribution, but using
the rate associated with the busiest time of day, not the 24 hour
average. The problem is going to be working out where all the
bottlenecks are, and estimating the queue delays.
A thread has significant memory overhead, and appears on operating
system queues. How much do you really need to remember about each client
between messages? If it is small, you are better off keeping a client
state object for each client. When a message comes in, allocate a thread
and select the appropriate client state object.
Patricia