Proper Send Batching

427 views
Skip to first unread message

Brandon Darling

unread,
Apr 28, 2021, 5:35:24 PM4/28/21
to masstransit-discuss
Is it possible to actually send messages in an actual batch. Lets say I have a batch of 10 messages, the current implementation just kicks off 10 threads and calls send on each one (implementation below).

Current Implementation:
 Task.WhenAll(messages.Select(x => endpoint.Send(x, pipe, cancellationToken)));

From a performance and cost perspective this is bad. I want one call made to Azure, not 10.

Thanks,

Brandon

Chris Patterson

unread,
Apr 29, 2021, 8:26:44 AM4/29/21
to masstrans...@googlegroups.com
MassTransit does not have a publicly surfaced batch send/publish API, primarily due to the transport requirements and how much they differ when it comes to batching.

And, if you've benchmarked (I have), there is no significant advantage to sending messages as a batch compared to using the .SendBatch() extension methods. I know, I've measured it.


The Azure client is a streaming client, so it doesn't do a full RPC handshake per message send.




--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/b1571e86-3343-4f4d-abbd-e2afca79a2ebn%40googlegroups.com.

Brandon Darling

unread,
Apr 29, 2021, 11:44:16 AM4/29/21
to masstransit-discuss
Thanks for the prompt response. It does make me feel better that the performance is on par; however, from a cost perspective it is still an order of magnitude higher. It would be a nice feature to have the ability to send all messages in actual batch vs one at a time.

Chris Patterson

unread,
Apr 29, 2021, 1:25:54 PM4/29/21
to masstrans...@googlegroups.com
Well, as I said, nothing in MassTransit is going to do that at this point.


Reply all
Reply to author
Forward
0 new messages