Redundant multi-threaded applications

we are trying to write a service for Windows and have to come up with a redundancy plan, so if something in the application fails, it will be restored again. I am wondering if I can use multithreading to accomplish this.

My idea is to create two threads, each of which handles separate tasks. I would also like for each thread to track a different thread, to make sure it still works, if it is not there, then it should start a new instance of this thread. Does this sound doable? What streaming methods would I use: mutexes, shared memory, semaphores, etc. ?? if this is not the right approach, then what could be, just write two separate services and use IPC?

+3
source share
4 answers

Well, the easiest way to get your service to restart if it fails is to let Windows do it. You just configure the service to automatically restart, it is very simple. You can also do this using the program installer. For help on how to do this, see this post: Building a Windows Service - Part 4: Extending the Service Installer .

Regarding this provision of "redundancy", it is not. The correct definition of redundancy means that you have more than one of them. This may be using multiple services or using multiple services on multiple hosts. Multiple services on the same host are simpler, as you can use the mutex to synchronize if necessary.

: ?

, , , . , . .

+4

, . , , ( ) , , - . , , .

+3

, Windows ( visual studio, ). , , - , , , - ...

, , . , , .

"" ( , - ), , , , .

: Windows

+2

, , , - , . WCF ( ) . , , , , . .

. . .

  • Watchdog , .
  • Watchdog , .
  • Watchdog , .
  • Watchdog , .

Windows 3 . , . , . Thread.Abort , , , .

In addition, try making your core logic as robust as possible. Thus, if you need to forcefully terminate it, it is much easier to restore and clear the mess that it left behind. This may mean using atomic operations such as DB transactions or smart file operations.

0
source

All Articles