Asterisk and FastAGI Fundamental

Hi guys,

I have written a Fast AGI application which does the remote database lookup, logging and few other things. My server is a preforking server which is already running on a remote system waiting for the call from Asterisk.

Here is my extension.conf:
exten => _1,1,Answer()
exten => _1,n,AGI(agi://
exten =>_1,n,Hangup()

I need some fundamental clarification: The server I am using for Fast AGI is a blocking server and when the call comes to Asterisk, Asterisk immediately hands it over to Fast AGI server and than all the activities are done by the application running on that Fast AGI server till the application ends. And only than the control again comes in extension.conf for hangup.

  1. Is this a advisable solution when it comes to reducing load from Asterisk server. Will this allow Asterisk to handle more calls?

  2. The processing my application does in significant. It store the data into remote database and logs every activity user does on his mobile like pressing DTMF. This log than helps me to know why the users are failing to understand a particular IVR call flow. Because the application is processor bound not the network bound I am thinking that a prefork or a multi threaded server will be useful compared to Asynchronous server.? What is your take on it?

  3. Is there any way to bring Apache Web server in place of my Fast AGI server? Apache 2 is an Preforking based MPM server and obviously will be better then my Fast AGI server. As anybody worked on it? May be some web service based server etc?


What did you write your FastAGI server in? I am not sure I understood you correctly, but did you write a single threaded blocking socket server?

The fact that you deployed all your business logic in the FastAGI server is fine. That is the point. Sometimes you need to come back to the dialplan, other times you don’t. No problem there.

I always program my FastAGI in a multi-threaded manner. I use the Asterisk-Java library with a custom Socket handler class… I found some serious flaws in their Socket code.

I don’t believe you could easily trick Apache into handling FasgAGI requests without some serious modification of the source code. If you are looking for a good multi-threaded socket framework, I am sure there are some open source ones out there… you just need to let us know what your preferred environment is.


Thanks for the reply. I am using preforking server (as I mentioned in my post) which is by nature a blocking server.

I am also looking at a Asynchronous TCP proxy server which can be used by this task. But instead of writing the code, I am looking to modify some existing open source TCP proxy server

Btw, you reply has relaxed me that my current approach is not bad.