[英]What's the right way to modify the params passed to controller in rails 3.1.0?
[英]What is right way to accept a lot of requests with Rails controller?
我的应用控制器接受来自第三方API(webhooks)的请求,但当它变为400 RPM时,我的网站出现故障(客户太多)。 我该怎么办?
class CallbacksController < ApplicationController
def acceptor
if params['type'] == 'confirmation' # this type is rare. only when client switches on callback
group_setting = GroupSetting.find_by_callback_token(params[:callback_token])
if group_setting
group_setting.update_attribute(:use_callback, true)
GroupSetting.new.callback_start(group_setting.group, group_setting.user)
render text: group_setting.response_string
else
render text:'ok'
end
else
CallbackWorker.perform_async(params[:callback_token], params['type'],
params['group_id'], params['object'],
params['secret'])
render text:'ok'
end
end
end
在我看来,你有一个Web服务器线程瓶颈。 你能指定你使用的服务器吗? 你能制作一个Apache Benchmark并发布结果吗? 也许有关您的设置的更多信息可能有所帮助。
如果您使用的是WEBrick,我建议您尝试使用PUMA 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.