Link to home
Start Free TrialLog in
Avatar of lbrindise
lbrindise

asked on

Multiple concurrent instances of a the same Windows Service on a single server

I have a process that will run as a service.  Each service will monitor a given instance of a machine.  If I have multiple machines, then I need multiple instances of the service to be running concurrently, one service for each machine.  Is it possible in VS2008, .NET 3.5 to change a config somewhere whereby the service will install with a slightly different name (something configurable), and that I can have different DB connection settings, etc, for each service?  
Thanks for any direction,
Larry
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I don't understand why you would need multiple instances of a Windows service
Avatar of lbrindise
lbrindise

ASKER

Sorry I wasn't clear.  
I want to have one server monitoring about 100 external devices across the internet.  Because of the synchronous nature of the machines I will be monitoring (they are not computers, rather dumb devices that support a web protocol), there is no way to setup an asynchronous callback architecture.  In other words, the service contacts the device across the internet, and then will wait several seconds for the roundtrip response to come back, and this is a synchronous wait.  Now, if I have 100 of these devices to monitor, there is no way I can have a single service waiting synchronously on each of these 100 devices - there aren't enough seconds in a minute, so-to-speak.  So, I am thinking that if I setup a separate service (a clone of the monitoring routine) for each of these external devices being monitored, then they can each individually be waiting on the synchronous call.  So, there would be 100 windows services, e.g., mon001, mon002, mon003, mon004, with mon001 pointing to device 001, mon002 pointing to device 002, etc.  Lots of services doing lots of synchronous waiting.  I just have to be able to identify each service and point each service to its individually monitored device.
I KNOW IT'S UGLY! :)  I'm open to other suggestions, and hope I'm just missing something obvious.
Thanks!
Would it be possible to distribute the processing, so that you wouldn't have one machine running the service, but a "service farm" of computers that are responsible for a block?
Your question makes me think it might be possible to simply spawn off a new thread for each request, and that way get around the synchronous wait.  However, I'd like to know if it is actually possible to have multiple instances of a service.  Hoping someone can give a definitive answer instead of a workaround (even though a workaround might be plausible).
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for th e link, and the discussion might have given me a better idea to implement the required architecture.  Very interesting.  I wonder why I couldn't find that Codeproject article based on my searching.  Thanks!