在我的Ruby on Rails应用程序中,我使用shoryouken进行后台处理.我的应用程序中有很多sqs队列(6-7).其中一个队列有2000-3000个作业,工作人员需要大约3个小时来处理这些2-3k个作业,默认并发数为25.因此,根据哪些因素,我们可以决定增加并发性(即处理作业的线程).如果问题中有任何不清楚的地方,请发表评论.
concurrency multithreading ruby-on-rails background-process shoryuken
作为 AWS 的一个相对新手,根据设置文档让 Shoryuken gem(带有 Active Job 和 Active Record)工作起来有点曲折。
中间件:我不确定中间件是否是设置的必要部分,因为它只在基本示例中产生。如果您需要在从队列中获取消息之前或之后执行操作,我的理解是否正确。
Shoryuken 插入但不从 SQS 获取消息:此时,Shoryuken 正在将消息传送到 SQS 队列,我可以在 AWS 控制台中看到消息(在可见的消息中),但 Shoryuken 没有获取它们以执行,即使其中没有任何内容队列。
安慰
irb(main):003:0> InvitationMailer.send_invite(ii).deliver_later
Enqueued ActionMailer::DeliveryJob (Job ID: 5c65184c-8656-42bd-95ce-e0ded78a9a44) to Shoryuken(development_mailers) with arguments: "InvitationMailer", "send_invite", "deliver_now", gid://projectname/Invitation/25
=> #<ActionMailer::DeliveryJob:0x007f7fad761a40 @arguments=["InvitationMailer", "send_invite", "deliver_now", #<Invitation id: 25, invite_code: "324234325", sender_id: 7, invitee_first_name: "Kylo", invitee_last_name: "Ren", invitee_email: "test128@somewhere.com", status: "sent", joined_member_id: nil, created_at: "2016-09-24 03:14:44", updated_at: "2016-09-24 04:16:36", invite_message: nil, sent_at: nil, accepted_at: nil, completed_at: nil, clicked_at: nil, source: nil>], …
Run Code Online (Sandbox Code Playgroud)