1

I have a feeling there is going to be a very simple answer to this one, but I'm going round in circles!

Basically I have a basic RMQ producer POC using both the standard .NET Core RMQ client as well as EasyNetQ. All is working fine, where as per the examples, a connection is created within the scope of the function and then disposed of after.

I then started doing some performance tests of the code and found that there is a serious performance issue with regard to throughput, and I think it may be because a new TCP connection is being created for every request.

So, I was wondering what the best method for creating a connection to RMQ was (which contains logic for detecting if the connection has died etc), maybe on application startup which was then available to controllers etc to be able to create channels and produce messages.

Can anyone help?! Thanks.

  • Take a look at [masstransit](http://masstransit-project.com/MassTransit/) it handles many thing for you, it provides retry mechanisms, error handling etc.. – Emre Savcı Sep 20 '18 at 16:49
  • You'll have to have an object that exists across requests (which isn't a big deal in .net). But, this is really too broad of a question to be answered here - I'd do a google search on that and see if you can come up with your own. I did it in my code, and it wasn't that hard. – theMayer Sep 20 '18 at 17:47
  • https://stackoverflow.com/questions/8919095/lifetime-of-asp-net-static-variable – theMayer Sep 20 '18 at 17:52
  • Yes, thanks. It was solved in the end with a static variable set on startup. – Robert Young Sep 21 '18 at 08:14
  • And just as a small bit of info for anyone reading in the future - this single change reduced response times (on a load test of 1000 clients across 10 containers running this app) from 700ms down to an average of 7ms!! Well worth doing.. .Just need to make sure you are checking the connection is still there before attempting to use it ;) – Robert Young Sep 21 '18 at 08:16

0 Answers0