Skip to content

High Performance

Sunny Ahuwanya edited this page Jan 27, 2016 · 5 revisions

RestBus uses high performance techniques to achieve high throughput.

For best results, use one client per service throughout your application and dispose the clients when your application ends. (In the near future, one RestBus client will be able to message multiple services, but it's not currently supported.)
RestBus clients are thread-safe and so can be used silmultaneously in different threads.

Do you want even higher throughput?


  • If your service takes a considerable amount of time to process a message, you can launch a new instance of the service to increase the rate of message consumption and possibly increase the message processing speed significantly, depending on the nature of the processing involved.

  • Consider skipping serialization ( Use RestBusClient.SendAsync() directly). You can send strings or binary objects to the server. This is not recommended unless your service is extremely time sensitive and you have full control of your environment.

  • Consider turning on automatic consumer acknowledgements in your server's subscriber:
var subscriber = new RestBusSubscriber(msgMapper, new SubscriberSettings
{
    AckBehavior = SubscriberAckBehavior.Automatic
});

This means all messages are automatically acknowledged once received by the server. The drawback is that if your server crashes while processing a message, the broker will not resend the message once the server comes back online, which makes your service less reliable.


  • If you are in a situation where you have to send a lot of messages that are readily available, for example, you have a lot of log files on disk that you need to transmit to another system, consider batching your messages.

RestBus is more efficient (to a limit) with larger messages. Instead of sending one File per message, consider sending List<File> instead. In this case, the service endpoint should expect List<File> and will process each file in the list appropriately.