[Chicago-talk] Design Question

Wiggins d'Anconia wiggins at danconia.org
Fri May 6 10:23:31 PDT 2005


JT Smith wrote:
>> I plan to have it running on 10 eventually.  Will
>> having 10 machines constantly querying the database
>> server
>> several times per second damage the server?  What is a
> 
> 
> I wouldn't say it would "damage" it, but you'll certainly make it very
> busy, and I think unneccesarily so.
> 
>> safe level of activity?  Does anyone know of a more
>> efficient way of designing such a program?
> 
> 
> Polling systems are insanely inefficient, but sometimes they're the only
> way to get the job done. In this case I think you have a much better way
> of doing it:
> 
> Set up an event handler server, I recommend using POE to write this, but
> you can certainly write your own. The perl script on your PBX can kick
> off an event to the event handler server each time a new call comes in.
> The event handler server can do whatever processing you need done
> (writing to the database, analyzing numbers for duplicates, etc). This
> way you never have to poll the database and you can handle a much larger
> number of calls and other processes.
> 
> One key to using an event handler like this is that it's an asynchronos
> process, therefore it can theoretically handle an unlimited number of
> transactions because as new transactions come in their placed on a queue
> and wait to be processed until the event handler server has time to deal
> with them.
> 

This is similar to what I was thinking but seems to re-engineer the
process already in place, it is still up to the individual machines to
poll the database which is what needs to be avoided, not the insertion
of the data, which presumably you wouldn't want queued?

I would use POE as well, but instead create a server that takes
connections from the client machines and hangs on to them, then when the
Perl script logs the data have it call an event on the server to
dispatch an message to each of the clients. Pretty standard setup I
would think. You could even go the UDP route since you may not really
care about who is listening or whether they get the message....

http://danconia.org


More information about the Chicago-talk mailing list