[英]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.