Hi,
Sorry for using the issue, but the discussion is not enabled.
Env
- RabbitMQ 4.1.0-beta.4
- Mac M1
- Single Quorum queue
- Single TCP connection
- Single Session
- Single Sender
Scope
Performance testing
Code
Given the following code:
for i := 0; i < 500_000; i++ {
...
r, err := sender.SendWithReceipt(ctx, amqp.NewMessage(make([]byte, 10)), nil)
if err != nil {
// deal with error
}
state, err := r.Wait(ctx)
if err != nil {
// deal with error
}
...
}
The rate is ~3.700 messages per second.
I tried a different approach, with:
type CallbackConfirmation func(message *amqp.Message, state DeliveryState, err error)
func (m *Publisher) PublishAsyncConfirmation(ctx context.Context, message *amqp.Message, callback CallbackConfirmation) error {
sendReceipt, err := m.sender.SendWithReceipt(ctx, message, nil)
if err != nil {
return nil
}
if atomic.AddInt32(&m.pending, 1) == int32(m.maxInFlight) {
m.condition.L.Lock()
m.condition.Wait()
m.condition.L.Unlock()
}
go func(sr amqp.SendReceipt) {
state, err := sr.Wait(ctx)
atomic.AddInt32(&m.pending, -1)
m.condition.Signal()
callback(message, state, err)
}(sendReceipt)
return nil
}
The send and confirmation "async" rate is ~ 35.747 messages per second, which is ~10 times faster.
Questions:
- Is my second approach safe? I am looking inside the code, and it should be secure. I just wanted to ask for more confirmation.
- Any advice about sending performance?
Thank you
Hi,
Sorry for using the issue, but the discussion is not enabled.
Env
Scope
Performance testing
Code
Given the following code:
The rate is ~3.700 messages per second.
I tried a different approach, with:
The send and confirmation "async" rate is ~ 35.747 messages per second, which is ~10 times faster.
Questions:
Thank you