Can we have same endpoint in two instance in same machine

nservicebus

(Raj Shelar) #1

Can we have same endpoint in two instance in same machine. I have infrastructural limitations hence do not wanted to add more machines.


(Sean Farmar) #2

What transport are you using? (i.e. MSMQ/RabbitMq/Azure?)


(Raj Shelar) #3

I am using Sql Server Transport.


(Ramon Smits) #4

Usually you would not need to run multiple instance of the same endpoint on the same machine. If you require more concurrent processing then you can increase this:

You can run multiple different endpoints on the same machine too.

Does this help?


(Raj Shelar) #5

Below link suggests
https://docs.particular.net/transports/msmq/distributor/

The default concurrency of the distributor process is set to 1. That means the messages are processed sequentially. Make sure that the MaximumConcurrencyLevel has been increased in the configuration on the endpoint that runs distributor process. A good rule of thumb to set this value to 2-4 times the amount of cores of a given machine. While fine-tuning, inspect disk, CPU and network resources until one of these reaches its maximum capacity.

I have octa-core processor, so can I have MaximumConcurrencyLevel=32 (8*4).


(Mauro Servienti) #6

Hi,

That link is for the distributor that is MSMQ bound, and you are using the SQL Transport.
The answer to your question has 2 sides.

Technically speaking there is nothing preventing you to deploy the same endpoint in multiple instances even on the same machine, this is especially true with broker based transport such as SQL Transport.
Given that you have a limitation on the number of machines, deploying multiple instances on a single box is probably the only way to achieve side-by-side deployments, if you also need them.

The other side of the answer is: it depends :slight_smile:, let me use a trivial sample.

Say that you have 10 messages in the queue, and only one single processing machine. You can deploy 10 instances each one with concurrency set to 1. All the messages in the queue will be processed in parallel. The same happens if you deploy 1 single instance with concurrency set to 10.
On a single machine finding the right balance is tricky, processes on Windows are not cheap, meaning that the overhead of creating and running a new process has an impact. Obviously processes cannot “scale up” indefinitely, there is a point when it’s better to create a new process. What counts the most in this case is:

  • throughput: how many messages are you processing?
  • what the handler is doing

So the answer to your question is: yes, you can run multiple instances of the same endpoint on the same machine. No technical limitations in doing that.
Is it better than changing the concurrency level? This is very hard to answer.

.m


(Raj Shelar) #7

Thank you. Any idea how can we create different instance for same endpoint. Do you suggest different windows service host with different name but carrying same endpoint?


(Mauro Servienti) #8

that’s the only option, when the Windows Service is installed it’s
installed from different paths for each instance and the Windows Service
name can be my-service-instance-1, my-service-instance-2, etc…


(Ramon Smits) #9

Raj, I still fail to see why you want to run multiple instance of the same endpoint on the same machine.

The info you are sharing is about concurrency. THere is only one good way in configuring that and that is measuring. Setup monitoring and experiment with different values. Start with small numbers, measure, increase, measure again, and try to find the limit.

If you have 20 endpoints on the same machine and all have their concurrency set to 50, then you have a sum of 1000 concurrent messages. If the machine is capable of of doing that depends on the type of load. So configure once, measure twice :slight_smile:

Running multiple instance of THE SAME ENDPOINT on the same machine is only useful if you do this temporarily to achive zero downtime deployments. Just running multiple instance of THE SAME ENDPOINT is not really efficient.

By the way, the default concurrency since V6 is already the set to the number of CPU cores which is likely to be 16 on your machine (8 cores with hyperthreading)

– Ramon