Re: [twsocket] ICS threaded server and load balancing

2006-06-19 Thread David Hooker
On 6/14/06, Francois Piette [EMAIL PROTECTED] wrote:

  OK, but what if I want one thread per CPU?
 
  So if I have a 4 CPU rig and 400 connections, I want to
  have 4 threads and 100 connections per thread.
  But if the load increases to 600 connections, I want to
  have 4 threads and 150 connections per thread.

  This si not a winsock or TCP/IP component issue. It is an OS issue. I
 don't
  know Windows has an API to force a thread to run on a given CPU. You
 have an
  API to know the number of processors.



Sorry, I wasn't clear enough.  I want to be able to balance connections over
threads.
So instead of having 100 connections per thread, and then creating a new
thread, and then
another 100 connections, and so on...   I want to have 4 threads and have
(number of connections at this present moment) / 4 connections per thread.

It is probably too much to ask for connections to migrate threads in
response to loading,
but it would be nice if new connections picked the thread that had the
fewest connections.
So I want to have a fixed number of threads, but balance the connections
evenly over those
threads.


Also, what is the behaviour of UDP and multiple threads?


Thankyou
David Hooker
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS threaded server and load balancing

2006-06-14 Thread Francois Piette
 OK, but what if I want one thread per CPU?

 So if I have a 4 CPU rig and 400 connections, I want to
 have 4 threads and 100 connections per thread.
 But if the load increases to 600 connections, I want to
 have 4 threads and 150 connections per thread.

This si not a winsock or TCP/IP component issue. It is an OS issue. I don't
know Windows has an API to force a thread to run on a given CPU. You have an
API to know the number of processors.

You can manage to have as much thread as CPU. But no ICS component will do
it automatically for you. You can use the standard TWSocketServer component
which is not multithreaded and have each TWSocketClient attached to one of
you threads using TWSocket.ThreadDetach and TWSocket.ThreadAttach.

Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


- Original Message - 
From: David Hooker [EMAIL PROTECTED]
To: twsocket@elists.org
Sent: Wednesday, June 14, 2006 4:23 AM
Subject: [twsocket] ICS threaded server and load balancing


 From borland.public.delphi.internet.winsock:

 Francois wrote:

  The server component will create a new thread as the previous one
reached
  the maximum number of client you've setup. It is the OS which schedule
the
  available CPUs to the threads in the ready state.




 OK, but what if I want one thread per CPU?

 So if I have a 4 CPU rig and 400 connections, I want to have 4 threads and
 100 connections per thread.
 But if the load increases to 600 connections, I want to have 4 threads and
 150 connections per thread.


 So far as I can tell, having one thread per CPU avoids serialisation
effects
 (ignoring any shared state or
 synchronisation).  Do you think that this might be faster than IO
completion
 ports (whose main benefits seem
 to be keeping all CPUs loaded and avoiding context switches)?



 Can this be done with UDP as well?  (Direct incoming datagrams to threads
in
 a load-balanced manner?)


 Thankyou for your time.
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS threaded server and load balancing

2006-06-14 Thread Primož Gabrijelčič
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Francois Piette
 
 This si not a winsock or TCP/IP component issue. It is an OS issue. I
 don't know Windows has an API to force a thread to run on a given CPU.

SetThreadAffinityMask

 You have an API to know the number of processors.

GetProcessAffinityMask

Best regards,
Primoz


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be