I am building a platform that will support logging data from IP connected devices. The logger uses a proprietary API to communicate with the connected devices and dump the data to the database. I'm using ASP.NET Web API to provide start/stop functionality for each logger.
In a stand alone server environment, I'd simply create a global variable that contains a list of live loggers. But that won't work in a load balanced environment. For instance, a post request by User A comes into Web 2 which creates a new logger on Web 2 (recording in the database that Web 2 has an active logger with X id). Then, a delete request by User B comes into Web 5. That request would need to talk to Web 2 to actually shut down the logger.
Is there a common practice for keeping track of long running processes and which IIS instance the process is running on? Is there a best practice for communicating between instances in a load balanced environment. I'm planning to use SignalR to communicate status to connected users.
If you have some links to actual code sample, that would be great!
Edit/Clarification
I have multiple devices on a local LAN that are controlled through a third party DLL. To control a specific device, an instance of a class defined in the third party DLL is created using the local LAN Ip Address of the device. With that class instance, the device can be turned, controlled and managed. Additionally, the device sends messages via TCP/IP that can be received via a callback method.
I want to expose control of these devices and messages from these devices through a web site that will be load balanced. A User (say Greg) can request through the website to start logging for any device in the device list (say Device at 192.168.1.51). My code will receive that request through a Web API post (say devices/51). Once received, I will spin up a new instance of the Device Logger API class and register the callback function. Incoming messages from the device via the callback will be pushed via SignalR to connected clients and written to the database for historical purposes. Another User (say Tim) can attach to the SignalR hub to view messages from Devices currently being logged. Tim can also stop live logging of the Device by submitting a delete request to the Web API (say devices/51).
I am looking for an example of intra-web server communication. Since the web site is in a server farm and the device logger API instance for device 51 lives on a specific web server, my web api delete for devices will need to communicate between web servers to shutdown the logging.
Maybe this is as easy as setting up a secondary SignalR hub for intra-web communication. Have all web servers register with the hub upon startup and then broadcast the command to the registered web servers. If the receiving web server has the class instance for that device, it executes the command, if not, it ignores the command.
Thoughts? Is there another way to communicate between web servers?