Relation between Tread Vs RAM Vs CPU

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hi,

I have two questions,

First, does anybody know how to quantify the relation between the number
of threads, the amount of RAM and the CPU power?

Secondly, does a System.Threading.Timer is lighter in used ressources
than using a thread ? why? Does it start/stop faster than a thread ? why?

This is very technical but I can't find ressource about that
specifically, if you have any web references, I would very appreciate.

Best regards,
Marty
 
Marty,

What kind of relation are you looking for? You can't say the OS can
handle X number of threads based on the amount of ram and CPU, or anything
of that nature. The best you can do is guess, and you also need a good deal
more information to make that guess anywhere close to accurate.

As for using a Timer instead of a thread, both do different things. The
timer will fire a notification after a certain period of time has elapsed.
A thread is a unit of execution which will be performed separately from
other threads. They have different purposes, so I am not quite sure what
your question is.
 
Hi Nicolas,

Thank you for your reply, I'll add more details to my query.

For my first question, I want to write some software specification and I
need to know if the number of threads will make increase the amount of
used RAM by the application.
-If I have 50 running threads (one thread for each client connection in
a server), how can I theorically evaluate the performance impact of that
on the system (at least RAM)?
-Does Microsoft can guaranty a specific amount of RAM per thread? (just
the thread object itself idling).

For my second question, I'll explain what I am doing right now.
1- A client connect to the server.
2- The server accept the connection and create a thread that will handle
this new client connection.
3- The thread will pool a queue created for that client.
4- When server sends messages to client, messages are firstly queued in
this queue (the flow is heavy, 100-1000 message per sec. (each msg = up
to 100bytes)
5- The thread will dequeue each message in the queue and send it to the
client through the socket.
6- When the thread dequeued all pending message, it sleep for 10ms.
7- Then thread awake and check if there is message to send to client.
Then do step 5, 6, 7 until the client disconnect or the server is closed.

The server can handle case 1 to 7 for 50 clients. Each client connection
has its own thread that has its own queue. Each client does not receive
the same message from the server.

Should I use a thread.timer instead of the current thread for step 1 to
7 to dequeue, in order to get full speed/performance of the server ?
Maybe the thread.timer will start/stop faster than the thread.sleep()?

I appreciate your suggestion.
Marty
 
Quantify what aspect? I take it you are thinking about thru-put, right?

Then in relative terms a quantification could be that more ram and more cpu
power allow for more threads.

That quantification is not complete and maybe even wrong but I think you
better switch to what you are actually trying to achieve. You can spend an
infinite amount of time trying to quantify the universe but your time is
limited. If you want to get work done, focus on that instead. You might get
better answers to your question as an added bonus.

Nicholas Paldino said:
Marty,

What kind of relation are you looking for? You can't say the OS can
handle X number of threads based on the amount of ram and CPU, or anything
of that nature. The best you can do is guess, and you also need a good
deal more information to make that guess anywhere close to accurate.

As for using a Timer instead of a thread, both do different things.
The timer will fire a notification after a certain period of time has
elapsed. A thread is a unit of execution which will be performed
separately from other threads. They have different purposes, so I am not
quite sure what your question is.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Marty said:
Hi,

I have two questions,

First, does anybody know how to quantify the relation between the number
of threads, the amount of RAM and the CPU power?

Secondly, does a System.Threading.Timer is lighter in used ressources
than using a thread ? why? Does it start/stop faster than a thread ?
why?

This is very technical but I can't find ressource about that
specifically, if you have any web references, I would very appreciate.

Best regards,
Marty
 
Back
Top