[Freeswitch-users] FS performance using ESL
Tihomir Culjaga
tculjaga at gmail.com
Tue Aug 16 16:44:16 MSD 2011
On Mon, Aug 15, 2011 at 6:30 PM, Anthony Minessale <
anthony.minessale at gmail.com> wrote:
> You must have something setup strangely cos it would definitely reduce
> your overall cps to use ESL but not down to 2 CPS.
>
> Did you look over the server stats like top etc and look for any
> misconfiguration?
>
> Hello Anthony, thanks for your response....
yay, i found the cause .... testserver and FS were running on the same
server. The server had just 1GB of RAM and of course ... by forking
testserver (on 8 CPS) took all the remaining RAM ending to write into swap
... this triggered a domino effect on the entire server becoming less and
less responsive as testserver started to run from swap!!!... yay .. really
bad... didn't see it happen until i started nmon ... top/htop didn't make it
in time to show this issue..
anyhow, i moved testserver to another machine reaching 35 CPS ... really
nice indeed.
now, having a referent point (testserver) im trying to reach that 35 CPS
with a java application.
yes, i notices few issues :=)
please check: http://pastebin.freeswitch.org/17052
------------------------------------snipp-----------------------------------
Control: full
// here i subscribe to all events ... well not good idea but its a start
events plain all
Content-Type: command/reply
Reply-Text: +OK event listener enabled plain
//and here i do a filter per uuid
filter Unique-ID f7a7b97b-df96-41f3-a6a3-fdf24350a45c
Content-Type: command/reply
Reply-Text: +OK filter added.
[Unique-ID]=[f7a7b97b-df96-41f3-a6a3-fdf24350a45c]
linger
Content-Type: command/reply
Reply-Text: +OK will linger
// here i send answer in sync mode ( i could change it into async)
sendmsg
call-command: execute
execute-app-name: answer
event-lock: true
Content-Type: command/reply
Reply-Text: +OK
Content-Length: 1805
Content-Type: text/event-plain
--------------------------------------------------------------------------------
so my questions:
if i use <action application="socket" data="192.168.254.99:8084 async
full"/> and if i subscribe to "myevents" i don't need to set a filter on
uuid and i could gain performance.
if i use <action application="socket" data="192.168.254.99:8084 async"/> i
will be getting events for the call in question only... so no special
filters needed and i could limit the number of events im subscribing
what is a better approach in a matter of performance ?
What do i loose/gain by using async full vs async mode ?
Thanks for your answer,
Tihomir.
>
> On Thu, Aug 11, 2011 at 6:56 PM, Tihomir Culjaga <tculjaga at gmail.com>
> wrote:
> > is there any other method than esl to controll calls on FS from an
> eternal
> > application?
> > will mod_curl or mod_xml_curl get better performance?
> >
> > T.
> >
> > On Fri, Aug 12, 2011 at 1:33 AM, Tihomir Culjaga <tculjaga at gmail.com>
> wrote:
> >>
> >> Hi Anthony, thanks for your response ...
> >>
> >>
> >> this is what i have:
> >>
> >> esl_filter(&handle, "unique-id",
> >> esl_event_get_header(handle.info_event, "caller-unique-id"));
> >> esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "CHANNEL_DATA
> >> CHANNEL_EXECUTE_COMPLETE CHANNEL_HANGUP");
> >>
> >> what do you suggest i put there ?
> >>
> >>
> >> is the inbound method less costly ?
> >>
> >>
> >>
> >>
> >> I modified testserver.c just a bit...
> >>
> >> #include <sys/types.h> /* include this before any other sys headers */
> >> #include <sys/wait.h> /* header for waitpid() and various macros */
> >> #include <signal.h> /* header for signal functions */
> >> #include <stdio.h> /* header for fprintf() */
> >> #include <unistd.h> /* header for fork() */
> >> #include <stdlib.h>
> >> #include <esl.h>
> >>
> >> void sig_chld(int); /* prototype for our SIGCHLD handler */
> >>
> >> static void mycallback(esl_socket_t server_sock, esl_socket_t
> client_sock,
> >> struct sockaddr_in *addr)
> >> {
> >> esl_handle_t handle = {{0}};
> >> int done = 0;
> >> esl_status_t status;
> >> time_t exp = 0;
> >>
> >> if (fork() != 0) {
> >> close(client_sock);
> >> return;
> >> }
> >>
> >> esl_attach_handle(&handle, client_sock, addr);
> >>
> >> esl_log(ESL_LOG_INFO, "Connected! %d\n", handle.sock);
> >>
> >> esl_filter(&handle, "unique-id",
> >> esl_event_get_header(handle.info_event, "caller-unique-id"));
> >> esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "CHANNEL_DATA
> >> CHANNEL_EXECUTE_COMPLETE CHANNEL_HANGUP");
> >>
> >> esl_send_recv(&handle, "linger");
> >>
> >> esl_execute(&handle, "answer", NULL, NULL);
> >> //esl_execute(&handle, "conference", "3000 at default", NULL);
> >> esl_execute(&handle, "playback", "/home/tculjaga/myWavFile.wav",
> >> NULL);
> >> //esl_execute(&handle, "sleep", "1000", NULL);
> >> //esl_execute(&handle, "hangup", NULL, NULL);
> >>
> >> while((status = esl_recv_timed(&handle, 1000)) != ESL_FAIL) {
> >> if (done) {
> >> if (time(NULL) >= exp) {
> >> break;
> >> }
> >> } else if (status == ESL_SUCCESS) {
> >> const char *type =
> >> esl_event_get_header(handle.last_event, "content-type");
> >> if (type && !strcasecmp(type,
> >> "text/disconnect-notice")) {
> >> const char *dispo =
> >> esl_event_get_header(handle.last_event, "content-disposition");
> >> esl_log(ESL_LOG_INFO, "Got a
> disconnection
> >> notice dispostion: [%s]\n", dispo ? dispo : "");
> >> if (!strcmp(dispo, "linger")) {
> >> done = 1;
> >> esl_log(ESL_LOG_INFO, "Waiting 5
> >> seconds for any remaining events.\n");
> >> exp = time(NULL) + 5;
> >> }
> >> }
> >> }
> >> }
> >>
> >> esl_log(ESL_LOG_INFO, "Disconnected! %d\n", handle.sock);
> >> esl_disconnect(&handle);
> >>
> >> close(client_sock);
> >>
> >> _exit(0);
> >> }
> >>
> >> /*
> >> * The signal handler function -- only gets called when a SIGCHLD
> >> * is received, ie when a child terminates
> >> */
> >> void sig_chld(int signo)
> >> {
> >> int status;
> >>
> >> /* Wait for any child without blocking */
> >> if (waitpid(-1, &status, WNOHANG) < 0)
> >> {
> >> /*
> >> * calling standard I/O functions like fprintf() in a
> >> * signal handler is not recommended, but probably OK
> >> * in toy programs like this one.
> >> */
> >> fprintf(stderr, "waitpid failed\n");
> >> return;
> >> }
> >> }
> >>
> >> int main(void)
> >> {
> >> struct sigaction act;
> >>
> >> /* Assign sig_chld as our SIGCHLD handler */
> >> act.sa_handler = sig_chld;
> >>
> >> /* We don't want to block any other signals in this example */
> >> sigemptyset(&act.sa_mask);
> >>
> >> /*
> >> * We're only interested in children that have terminated, not
> >> ones
> >> * which have been stopped (eg user pressing control-Z at
> >> terminal)
> >> */
> >> act.sa_flags = SA_NOCLDSTOP;
> >>
> >> /*
> >> * Make these values effective. If we were writing a real
> >> * application, we would probably save the old value instead of
> >> * passing NULL.
> >> */
> >> /* if (sigaction(SIGCHLD, &act, NULL) < 0)
> >> {
> >> fprintf(stderr, "sigaction failed\n");
> >> return 1;
> >> }
> >> */
> >> signal(SIGCHLD, SIG_IGN);
> >>
> >> esl_global_set_default_logger(0);
> >> esl_listen("localhost", 8088, mycallback);
> >>
> >> return 0;
> >> }
> >>
> >>
> >>
> >>
> >> On Thu, Aug 11, 2011 at 9:59 PM, Anthony Minessale
> >> <anthony.minessale at gmail.com> wrote:
> >>>
> >>> try removing the filter and event subscriptions
> >>> it's costly to consume all of the events especially at 75cps.
> >>>
> >>>
> >>> On Thu, Aug 11, 2011 at 5:23 AM, Tihomir Culjaga <tculjaga at gmail.com>
> >>> wrote:
> >>> > hello,
> >>> >
> >>> > im wondering how much performance do we loose when using ESL instead
> of
> >>> > running it via dialplan?
> >>> >
> >>> >
> >>> > without ESL with a fine tuned FS and a short dialplan ( answer,
> >>> > playback
> >>> > like 20 seconds file, hangup ) im able to service 75 CPS. On the same
> >>> > FS,
> >>> > when i use ESL to answer the call, playback the same file and hangup,
> >>> > im not
> >>> > able to run more than 2 CPS... this is a huge impact and i really
> can't
> >>> > believe it.
> >>> >
> >>> > I'm using event-socket outbound e.g.:
> >>> >
> >>> > <action application="socket" data="127.0.0.1:8088 async full"/>
> >>> >
> >>> > my extension looks like:
> >>> >
> >>> > <extension name="ESL_C">
> >>> > <condition field="destination_number" expression="^(6666)$">
> >>> > <action application="socket" data="127.0.0.1:8088 async full"/>
> >>> > <action application="sleep" data="1000"/>
> >>> > <action application="hangup"/>
> >>> > </condition>
> >>> > </extension>
> >>> >
> >>> >
> >>> > im using testserver from lib/esl/ and i just removed the conference
> >>> > command
> >>> > and added the playback one.... also i moved the esl_debug lvl to 0
> >>> >
> >>> >
> >>> > anyhow, FS cannot run more than 2 CPS compared to 75 CPS when the
> >>> > playback
> >>> > is done from the dialplan.
> >>> >
> >>> >
> >>> > Please, can someone give me a clue on what is going on?
> >>> > Maybe im doing something wrong?
> >>> > how to get maximum FS performance using ESL ?
> >>> >
> >>> >
> >>> >
> >>> > Regards,
> >>> > Tihomir.
> >>> >
> >>> >
> >>> > _______________________________________________
> >>> > Join us at ClueCon 2011, Aug 9-11, Chicago
> >>> > http://www.cluecon.com 877-7-4ACLUE
> >>> >
> >>> > FreeSWITCH-users mailing list
> >>> > FreeSWITCH-users at lists.freeswitch.org
> >>> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >>> >
> >>> > UNSUBSCRIBE:
> http://lists.freeswitch.org/mailman/options/freeswitch-users
> >>> > http://www.freeswitch.org
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Anthony Minessale II
> >>>
> >>> FreeSWITCH http://www.freeswitch.org/
> >>> ClueCon http://www.cluecon.com/
> >>> Twitter: http://twitter.com/FreeSWITCH_wire
> >>>
> >>> AIM: anthm
> >>> MSN:anthony_minessale at hotmail.com
> >>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
> >>> IRC: irc.freenode.net #freeswitch
> >>>
> >>> FreeSWITCH Developer Conference
> >>> sip:888 at conference.freeswitch.org
> >>> googletalk:conf+888 at conference.freeswitch.org
> >>> pstn:+19193869900
> >>>
> >>> _______________________________________________
> >>> Join us at ClueCon 2011, Aug 9-11, Chicago
> >>> http://www.cluecon.com 877-7-4ACLUE
> >>>
> >>> FreeSWITCH-users mailing list
> >>> FreeSWITCH-users at lists.freeswitch.org
> >>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >>> UNSUBSCRIBE:
> http://lists.freeswitch.org/mailman/options/freeswitch-users
> >>> http://www.freeswitch.org
> >>
> >
> >
> > _______________________________________________
> > Join us at ClueCon 2011, Aug 9-11, Chicago
> > http://www.cluecon.com 877-7-4ACLUE
> >
> > FreeSWITCH-users mailing list
> > FreeSWITCH-users at lists.freeswitch.org
> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> > http://www.freeswitch.org
> >
> >
>
>
>
> --
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org
> googletalk:conf+888 at conference.freeswitch.org
> pstn:+19193869900
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110816/20f9bfc1/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list