[Freeswitch-users] Best practices / tips for Event socket daemon
vladrodionov at gmail.com
Fri Aug 7 19:42:38 PDT 2009
Forking process on every incoming event is terrible idea IMO. Threads are
more lightweight than processes.
Can you use threads in PHP? I am not familiar with PHP (Java developer
myself). I can explain how I would implement it in Java.
There is one SocketReader thread and several Worker threads in a thread
"SocketReader" thread - reads data (events) from socket. When event arrives
SocketReader checks thread pool, get one Worker (if any) and makes it to
process event. If there no available Workers in a pool then event goes
directly to a EventQueue. When Worker finishes it checks EventQueue and if
there are no events in a queue Worker goes back to thread pool, otherwise it
process event from queue.
On Fri, Aug 7, 2009 at 5:23 PM, Nicolas Brenner <nicolas at medularis.com>wrote:
> Hi, I built an event socket daemon that waits for certain events, when it
> receives those events, it does some processing and keeps waiting for more
> events. The daemon is written on PHP and uses a slightly modified version of
> fs_sock.php (from contrib/intralanman/PHP/fs_sock/).
> What I am doing / what I want to do: I am generating calls and bridging
> them using a JS script. Then the daemon logs the info about the calls and
> keeps track of their status in a database.
> The problem is: the daemon is apparently missing out on some events, and I
> think it is because of the processing/updating on the DB it has to do each
> time it "catches" an event on the socket.
> My question is: which language would you recommend for the task, and how
> would you go about handling events? Should the dameon fork a process for
> each event it receives so that it doesn't miss any events? should there be
> more than one daemon? ... any tips and recommendations are welcome.
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the FreeSWITCH-users