streadway / amqp

Go client for AMQP 0.9.1
http://godoc.org/github.com/streadway/amqp
BSD 2-Clause "Simplified" License
4.88k stars 621 forks source link

Scaling multiple publisher subscriber configuration pubsub fanout #347

Closed febytanzil closed 5 years ago

febytanzil commented 6 years ago

Hi, need some helps from you guys, trying to use fanout exchange as described pubsub pattern https://www.rabbitmq.com/tutorials/tutorial-three-go.html https://github.com/streadway/amqp/blob/master/_examples/pubsub/pubsub.go

Problem

  1. Let say I have a subscriber function that listen to a specified exchange name then I want that subscriber to be spawned > 1 go routines in my main.go for scaling
  2. Let say I want a publisher function that can publish to any exchanges I want

    Questions #1

    • How to configure the Connection & Channel? Suppose I want 5 go routines, should I
    • set 5 Connection w/ 1 Channel each
    • set 1 Connection w/ 5 Channel
    • What is ChannelMax in Config struct used for? Will this give error if we try to open channel more that specified in that connection or is this a pool mechanism when we try to open a channel? Or something else?
    • When do I need to close conn and or channel?

      Questions #2

    • Is it possible to do that with 1 Connection and or 1 Channel?
michaelklishin commented 5 years ago

Thank you for your time.

Team RabbitMQ uses GitHub issues for specific actionable items engineers can work on. GitHub issues are not used for questions, investigations, root cause analysis, discussions of potential issues, etc (as defined by this team).

We get at least a dozen of questions through various venues every single day, often light on details. At that rate GitHub issues can very quickly turn into a something impossible to navigate and make sense of even for our team. Because GitHub is a tool our team uses heavily nearly every day, the signal/noise ratio of issues is something we care about a lot.

Please post this to rabbitmq-users.

Thank you.

michaelklishin commented 5 years ago

See Connections and Channels guides. A single connection with 5 channels and 5 goroutines is optimal for a lot of cases. You can also use one channel but note that handling of recoverable errors happens on the per channel basis, so I'd say 5 channels may be a more resilient, easier to reason about design in that sense. Otherwise you definitely can get quite far with just one channel.