Re: [Twisted-Python] [Q] Naming Service for Twisted Servers

2009-01-11 Thread Esteve Fernandez
On Saturday 10 January 2009 23:27:18 Don Smith wrote:
> Why not use a Message Queue? I developed a very similar program to what you
> have described, only each agent would connect to the Queue to get their
> data to work on. However, I think something like Apache ActiveMQ or
> AmazonSQS would be a better approach.

There's also AMQP [1], and (shameless plug) a Twisted-friendly library called 
txAMQP [2], which includes support for easy RPC using Thrift.

Cheers.

1 - http://amqp.org/
2 - https://launchpad.net/txamqp

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] connectionLost not always getting called?

2009-01-11 Thread Rob Bredow
I've implemented a twisted server using the basic.lineReceiver class.  The
client is a socket based client implemented in flash and the connections are
long-lived (minutes or hours).  To handle cleaning up the players when they
disconnect, I'm using the connectionLost function in my player class.  99%
of the time, things work as expected.

However in rare cases, connectionLost is not getting called when the
flash-based client disappears.  Even completely quitting the client's
web-browser does not always trigger a connectionLost call.  I tracked down
one specific instance yesterday where the server thought the client was
still connected even though the client had been gone for 30+ minutes--but
after a few hours the server noticed that the client was gone and then
connectionLost was called like normal.  That made me think that it might be
a problem on the server side and maybe not client related.

I'm starting on a workaround now where the client will issue a "PING" every
30 seconds and the server will use the ping information to manually trigger
loseConnection when needed.  Are there a better workarounds for this, better
practices or some error checking I can do to avoid these intermidant laggy
connectionLost calls?

Thanks in advance.

Rob

P.S.  I've found twisted to have incredible performance compared to
everything else we've tried.  If you're interested you can see the client at
http://www.guessasketch.com/ .  I'm happy to post server code excerpts if it
would be helpful.
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] [Q] Naming Service for Twisted Servers

2009-01-11 Thread V S P
Hi, I thought that 
MQ is quite 'heavy' for my needs 

Basically the whole system allows users to request 'reports'
and those reports can rung for days (or hours).

Instead of having 'one' persistent queue (or a service)
such as provided for typical MQ implementations -- I thought
just to have a 'little' message queue that for each user -- that
would be visible from their profile
(since there is no 'admin' interface to administer 'jobs' as in typical
message queues)


So I just simply planned a process scan each profiles queue,
and send the job requests in round robin to available twisted servers.

You might ask -- well you will store events to be dispatched in 
a table with profile IDs -- so that's what message queues do anyways.

However, the system is built such there is more than one database
instance
(where users are destributed based on a hashing scheme acrsoss multiple
databases) -- so it is not simply one table (that's also why there is
a need for multiple Twsited servers  as they would serve their own
'partitions' in the system)


On the other hand ... may be I need to look at open source and free
MQ solutions to see if I is easier to 


Thank you again for all the suggestions so far,
I am writting up a small summary of the replies for
furthere analysis.

On Sat, 10 Jan 2009 14:27:18 -0800, "Don Smith" 
said:
> Why not use a Message Queue? I developed a very similar program to what
> you
> have described, only each agent would connect to the Queue to get their
> data
> to work on. However, I think something like Apache ActiveMQ or AmazonSQS
> would be a better approach.
> 
> =Don
> 
> 2009/1/9 V S P 
> 
> > Thank you for the replies.  Wanted to make sure I was not missing
> > a 'twisted goodie'
> >
> > What is ZeroConf?  Can you please point me to the project page
> > (I searched for some but did not find something twisted/python
> > specific).
> >
> > my client will be a program that reads rows of 'requests' from the
> > database and dispatch them to available twisted servers (I call it
> > Dispatcher).  Then twisted servers will use the pool of worker threads
> > (with help of Ampula plugin I guess) to do the work (that will take
> > hours
> > of not more).
> >
> > So there will be just one program that needs to be
> > aware of all the available servers in my scenario.
> >
> > Also I can see that some people might have needed a 'proxy'
> > that sits infront of the cluster of twisted servers and that proxy
> > has some balancing mechanism.  And if there is any body that has that
> > solution I would like to know as well.
> >
> >
> >
> > thank you again.
> >
> >
> > On Fri, 9 Jan 2009 22:29:22 -0500, "Jarrod Roberson"
> >  said:
> > > 2009/1/9 V S P 
> > >
> > > > Hi,
> > > > I am sorry I am reasking the same question I asked before
> > > > (but I did not get any replies)
> > > >
> > > > Basically wanted to know -- for running Twisted on multiple servers
> > > >
> > > > is there such a thing as a "Naming" server that
> > > > would register all the currently running twisted servers
> > > >
> > > > -- so that asynchronious event dispatching can be done in some
> > > > round-robin to available twisted servers
> > > >
> > > >
> > > > we used ZeroConf for autodiscovery that way the clients can decide for
> > > themselves which server to connect to.
> > --
> >   V S P
> >  torea...@fastmail.fm
> >
> > --
> > http://www.fastmail.fm - And now for something completely different┘
> >
> >
> > ___
> > Twisted-Python mailing list
> > Twisted-Python@twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
-- 
  V S P
  torea...@fastmail.fm

-- 
http://www.fastmail.fm - IMAP accessible web-mail


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] [Q] Naming Service for Twisted Servers

2009-01-11 Thread V S P

Thank you for all the replies regarding my question
of the Twisted Naming Server and in general multi-machine Event
Dispatching systems.

So far my understanding from all the replies is as follows

1) there is no pre-built naming server for twisted

2) there is no multi-machine message/event dispatching for twisted
(but there is, of course, a communication mechanism called Prospective
Broker)

3) for message/event dispatching people use Message Queue brokers
http://activemq.apache.org/  (Java)
or more peer-oriented http://www.openamq.org/  (C++ but no windows
support)

4) Naming service is considered to be part of 'Resource Discovery'
and therefore generic resource discovery tools can be deployed
such as Apple's Bonjour or Avahi (C, does not support windows)

5) Message Queueing / Brokers have several python libraries available
and some of them are already 'twisted-friendly'
such as https://launchpad.net/txamqp for O-AMQ
or http://pypi.python.org/pypi/stomper/0.1.0 for MQ 


6) message queuing servers, of course, already have name service
(that's part of the solution)

7)dbus-python library for python (the one that can be used to
communicate
with Bonjour or Avahi) appeared to be difficult to deploy.  
However, bonjour or Avahi specific python clients/examples are available
http://www.indelible.org/ink/twisted-bonjour/
http://avahi.org/wiki/PythonPublishExample


8) I did not ask this question -- but I was struggling to understand
how people implement long-running DB requests queries in twisted if it
if the whole framework is just single threaded (because of python GIL)
and cannot use more than one CPU core in parallel.

So far my understanding on that is as follows:
   a) Twisted developers can use Ampula for creating a pool of processes
   and asking the processes do the work (processes run an independed
   python
interpreter).  
   b) Twisted threads, while will use global lock on python operations
   -- will call concurently the C-level libraries that do database
   access (or other activities that are implemented in C libraries).  So
   the Twisted Event loop will not block waiting for a DB to respond, as
   long as the DB request was issued from a Thread.
   c) Twisted (now including Asynchronious event loop)
 works on JPython -- and that one (unlike CPython) has a fully threaded 
( and may be even more efficient) virtual machine and garbage collector.



Vlad
-- 
  V S P
  torea...@fastmail.fm

-- 
http://www.fastmail.fm - Faster than the air-speed velocity of an
  unladen european swallow


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] connectionLost not always getting called?

2009-01-11 Thread Jean-Paul Calderone

On Sun, 11 Jan 2009 15:55:03 -0800, Rob Bredow  wrote:

I've implemented a twisted server using the basic.lineReceiver class.  The
client is a socket based client implemented in flash and the connections are
long-lived (minutes or hours).  To handle cleaning up the players when they
disconnect, I'm using the connectionLost function in my player class.  99%
of the time, things work as expected.

However in rare cases, connectionLost is not getting called when the
flash-based client disappears.  Even completely quitting the client's
web-browser does not always trigger a connectionLost call.  I tracked down
one specific instance yesterday where the server thought the client was
still connected even though the client had been gone for 30+ minutes--but
after a few hours the server noticed that the client was gone and then
connectionLost was called like normal.  That made me think that it might be
a problem on the server side and maybe not client related.

I'm starting on a workaround now where the client will issue a "PING" every
30 seconds and the server will use the ping information to manually trigger
loseConnection when needed.  Are there a better workarounds for this, better
practices or some error checking I can do to avoid these intermidant laggy
connectionLost calls?


This is a FAQ, so I've just added it to the FAQ.  Please let me know what
you think of the entry:

http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#WhyisntmyconnectionLostmethodcalled

Jean-Paul

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] connectionLost not always getting called?

2009-01-11 Thread Andrew Bennetts
Rob Bredow wrote:
[...]
> web-browser does not always trigger a connectionLost call.  I tracked down one
> specific instance yesterday where the server thought the client was still
> connected even though the client had been gone for 30+ minutes--but after a 
> few
> hours the server noticed that the client was gone and then connectionLost was
> called like normal.  That made me think that it might be a problem on the
> server side and maybe not client related.
> 
> I'm starting on a workaround now where the client will issue a "PING" every 30
> seconds and the server will use the ping information to manually trigger
> loseConnection when needed.  Are there a better workarounds for this, better
> practices or some error checking I can do to avoid these intermidant laggy
> connectionLost calls?

This is a property of TCP.  If a peer drops off the network suddenly, your side
never receives a RST packet, and if your side never tries sending to a dead
connection like this then TCP won't notice that the peer is now unreachable.

You can probably enable something called "TCP keepalives" in your OS, but
they'll still tend to take a few hours to notice an unreachable peer.  So your
workaround is about as good as it gets.

-Andrew.


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] connectionLost not always getting called?

2009-01-11 Thread glyph


On 01:27 am, exar...@divmod.com wrote:
This is a FAQ, so I've just added it to the FAQ.  Please let me know 
what

you think of the entry:

http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#WhyisntmyconnectionLostmethodcalled


Thanks for finally adding that to the FAQ.  It seems to me that it's 
important to clarify that this is a problem with TCP, not with Twisted, 
before getting into the details, though; communicating that a non- 
Twisted program would have this same problem.  You want me to have a go 
at editing it?


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] connectionLost not always getting called?

2009-01-11 Thread Rob Bredow
Thanks so much for the quick help.  I had done some searching and stumbled
into that 2 hour TCP/IP limitation but I didn't find anything as clear as
your FAQ entry.  My messages every 30 seconds seem to have solved my issue
and I'm glad to know it's a TCP/IP thing not related to my server or
twisted.

Thanks again.

-Rob
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] [Q] multi-process chat client and poller

2009-01-11 Thread Valentino Volonghi


On Jan 3, 2009, at 2:32 PM, V S P wrote:


Thank you so much
Yes, this plugin is what I am looking for process pool
"
   """
   This plugin provides ways to create a process pool service in your
   system listening on a given port and interface and answering to a
   given set of commands.
   """
"

So I just need to inherit from
AMPConnector and have a trully scalable server!


No. Wait there... AMPConnector is only a frontend and it's not
made to be inherited. You might want to inherit it only to add some
weird functionality to it. Another option is to not use it but create
a new one to avoid using AMP as a child-parent protocol.

You really want to subclass AMPChild and create a good AMPParent
by subclassing amp.AMP.

There are some examples in the code and to expose a process pool
on the net you shouldn't do anything more than adding the right argument
to the command line twistd plugin.


Two more questions:

What's the mechanism of 'registring' multiple twisted servers
(something similar to a Name server in Corba) -- so an event
dispatching client can 'discover' the servers running on
multiple machines


I haven't written such a mechanism yet. It shouldn't be too hard to have
a simple version but having everything go through the same master node
is kind of problematic from a scalability point of view. It would be  
better to

have a routing system where each system knows each other but probably
this has a lot of memory overhead to keep in memory the list of nearby
servers... If anyone is willing to spend some time to design some kind  
of
solution for this I'd be happy to implement it in ampoule. I'm pretty  
sure that

this was done in other projects already.


And how does one run multiple XAMPP servers in twisted -- such
that work to each server is distributed either by a hash on a user
name or some other way (or does such mechanism exist).


It's just AMP, XMPP is another protocol.

--
Valentino Volonghi aka Dialtone
Now running MacOS X 10.5
Home Page: http://www.twisted.it
http://www.adroll.com



PGP.sig
Description: This is a digitally signed message part
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python