[Twisted-Python] robust listenUDP with N clients?
marcbohlen at acm.org
Mon Dec 4 13:32:29 EST 2006
Jean-Paul Calderone wrote:
> On Mon, 04 Dec 2006 12:05:29 -0500, marc bohlen <marcbohlen at acm.org>
>> Jean-Paul Calderone wrote:
>>> On Mon, 04 Dec 2006 10:28:57 -0500, marc bohlen <marcbohlen at acm.org>
>>>> hi folks
>>>> I am new to twisted and new to server programming. Nonetheless, I
>>>> would like to build a robust client-server looping mechanism in
>>>> which a server would listen for input from N clients, say 10, and
>>>> react immediately when it receives data from them. I have a sample
>>>> (see below) that appears to run well, but am not sure if it will
>>>> scale under real network load and larger N.
>>>> (I am parsing the input data received from the clients and using it
>>>> to calculate a fibonnaci series, just for testing. The reactor can
>>>> be stopped with keyboard input (I am on a win32 platform)).
>>>> If you see any problems with this approach, please let me know !
>>>> Thanks, marc
>>> You probably need to be more specific to get many useful responses.
>>> do you expect N to go to? Why do you use multiple ports? Why are you
>>> using UDP? What do you mean by "robust"? What does the Fibonnaci
>>> have to do with the application? Is the keyboard input handling code
>>> relevant or just part of the example? Is win32 your development
>>> or your deployment platform or both?
>> Hi Jean-Paul
>> I would want N no larger than 30.
> 30 is quite small. There should be no performance issues related to
> the network layer.
>> I am testing only on localhost and have N ports instead of N
>> computers for now.
> Okay. So ultimately it will be 1 port communicating with N computers,
> instead of the current N ports all communicating with 1 computer?
>> Fibonnaci calculation: just a cpu cycle eating app for testing, will
> I don't think your original example realistically represented CPU load.
> It seems more likely that you will have some work to do in response to
> each request, which corresponds to datagramReceived
>> Keyboard handling is important.
>> Win32 is development and deployment platform.
> Win32 is pretty crummy. I have no idea how well anything will work on
> it. I generally assume that it won't, at all.
>> UDP choice: I would like the faster of the two protocols (UDP vs
>> TCP), although TCP has congestion
>> control. Is TCP the better choice here?
> If that's the primary metric, TCP is a better choice.
Then I'll use TCP.
>> Robust: will it work even under heavy network load
> If _that's_ the primary metric, TCP is still a better choice. :)
Yes, that is correct, N computers, one port.
If 30 is a small number, what would be a large one; what is the upper limit?
I'll use TCP then (and move the code over to a suse box :) )
thanks for the tips,
More information about the Twisted-Python