2

I have Asterisk and Rails app running on the same server. All inbound calls via Asterisk triggers a "curl" to the rails app's controller to initiate a juggernaut publish, enabling real-time push of inbound calls to the individual logged in user (Pop-up dialog showing caller profile details).

The problem is, the Passenger Spawner of the rails app is running at almost 100% CPU usage when ever calls starts coming in. Each inbound phone call will run:

/usr/bin/curl http://parlo.local/asterisk/inbound_call?exten=8405&src_num=921187888&recordingfilename=q70001-20

In asterisk controller:

def inbound_call
  if params[:src_num].length > 6
    extension = AsteriskUserextension.find_by_extension(params[:exten])
    if extension.present? && extension.user.present?
      @user = extension.user
      customer = Customer.first_match(params[:src_num]).first
      customer_name = customer.present? ? customer.full_name : "Unknown Caller"
      queue = AsteriskQueue.find_by_name(params[:queue])
      @result = Asterisk::Action.response_factory("asterisk_inbound","#{queue.try(:title)}","OK",customer.try(:id))
      publish
    end
  end
  render :nothing => true, :status => :created
end

I believe the high inbound call rate is causing the high CPU usage. What is the best way to remedy this situation? Will pushing all the work to RESQUE help?

Thanks for any guidance!

Adrian Teh
  • 1,929
  • 18
  • 15

1 Answers1

0

You need use FastCGI technology.

Also you need in asterisk use CURL function instead of System application.

Every call to System create shell and fork new proccess.

Also it can be nice idea check asterisk events via AMI instead of dooign CURL.

arheops
  • 15,544
  • 1
  • 21
  • 27