[Mongrel] Requests that make calls from XMLRPC::Client tie up Mongrel

Thomas Allen thomas.allen at litsoftllc.com
Wed Nov 18 12:31:38 EST 2009


Hi Everyone,

I'm running a Rails site on Mongrel and I can't figure out why a
particular type of request ties up Mongrel easily. The requests that
tie up Mongrel call an XML-RPC server like so:

# In the controller
def site_start
  if params[:id]
    @site = Site.find(params[:id])
    @site.site_start
    render :json=>{:success=>true}
  end
end

# In the model
def site_start
  RpcTask.manage(self, 'start')
end

# In RpcTask
def manage(site, task)
  run('manage_task', {
    :site => site.name,
    :site_id => site.id,
    :task => task
  })
end

# which calls
def run(task, task_params = {})
  begin
    server = XMLRPC::Client.new2('http://localhost:9192/')
    result = server.call_async(task,task_params)
    return result
  rescue XMLRPC::FaultException => err
    logger = ActiveRecord::Base.logger
    logger.error(err.faultCode)
    logger.error(err.faultString)
    logger.error(result)
  end
  false
end

If I call the model method directly from the console, the RPC side
responds very quickly:

>> start = Time.now; Site.first.site_start; (Time.now - start).to_s
=> "0.493253"

Removing the body of RpcTask.run results in comparable performance.
Also, by switching from a single mongrel to a four-mongrel cluster, I
was able to get the these actions to perform acceptably but I imagine
that I'm doing something very wrong here to require so much power. Any
ideas?

Thanks,
Thomas Allen


More information about the Mongrel-users mailing list