【发布时间】:2025-12-10 15:35:01
【问题描述】:
我在我的ruby项目中使用RabbitMQ(AMQP)已经有一段时间了,反正我只是听说过RabbitMQ集群,任何人都可以简单介绍一下,我需要知道运行普通RabbitMQ服务器的区别和 RabbitMQ 集群,我为什么需要它以及如何实现它。
我需要我的解决方案具有可扩展性并处理如此多的请求,我正在考虑以下实现,我很想知道如何实现这样的事情:
HA proxy->3 Clustered RabbitMQ instances
处理请求的最快方式和最佳 ruby Web 服务器选择是什么,只需解析它并将其发送到适当的队列。
在我当前的实现中,我正在使用瘦服务器并执行以下操作,但正在寻找更快且更具可扩展性的更好架构:
require "bunny"
require "thin"
@amqp ||= Bunny.new(:logging => false)
@amqp.start
@direct_exchange ||= @amqp.exchange('')
app = Proc.new do |env|
req = Rack::Request.new(env).params
command = req['command'].strip rescue "no command"
number = req['number'].strip rescue "no number"
if command =~ /\A(create|c|r|register)\z/i
@direct_exchange.publish(number, :key => "create")
elsif command =~ /\A(update|u)\z/i
@direct_exchange.publish(number , :key => "refresh")
end
[200, {'Content-Type' => "text/plain"} , command ]
end
Rack::Handler::Thin.run(app, :Port => 4001)
我确信有更好的实现。
任何帮助/提示将不胜感激。
提前致谢
【问题讨论】: