[Freeswitch-users] FS performance using ESL
Tihomir Culjaga
tculjaga at gmail.com
Fri Aug 12 03:56:06 MSD 2011
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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110812/b61ac371/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list