简体   繁体   English

分布式并行批处理

[英]Distributed parallel batching

I am trying to figure out a solution for a problem statement. 我正在尝试找出问题陈述的解决方案。 For simplicity's sake the application is going to be a console app. 为简单起见,该应用程序将成为控制台应用程序。 A database contains some 10000 rows. 一个数据库包含大约10000行。 I have a to develop ac# application which will spawn out 10 threads and each thread will process 5 records from the database. 我有一个要开发的ac#应用程序,它将产生10个线程,每个线程将处理数据库中的5条记录。 Now the thing is i will run the same application in another machine. 现在,问题是我将在另一台计算机上运行相同的应用程序。 So we have two instance of he application and each application should process 5000 rows and they should not overlap on the records. 因此,我们有两个应用程序实例,每个应用程序应处理5000行,并且它们在记录上不应重叠。 Also i need to have a central controller which needs to display the thread ids that are running on each application. 我还需要一个中央控制器,该控制器需要显示每个应用程序上运行的线程ID。 Any pointers here to solve this problem would be great. 这里解决这个问题的任何指针都是很棒的。

I would create a 'Processing Status' column in the DB and each instance will mark the records it's processing by changing record's status. 我将在数据库中创建一个“处理状态”列,每个实例将通过更改记录的状态来标记其正在处理的记录。

Another solution is to use a queue or Service Broker and each instance would be picking a message to process a record from common queue. 另一个解决方案是使用队列或Service Broker,并且每个实例都将从公共队列中选择一条消息来处理记录。 You will need another process here that will populate the queue. 您将在此处需要另一个将填充队列的进程。

Using WCF to communicate between machines to synchronize work is IMHO too complex and tricky to get right. 恕我直言,使用WCF在机器之间进行通信以同步工作太复杂而棘手,难以正确处理。

I agree with Jakub. 我同意雅各布。 If you want the separate instances to communicate with each other directly you should read about the Two Generals problem (http://en.wikipedia.org/wiki/Two_Generals%27_Problem) and think about how you're going to design a non blocking rendezvous without races. 如果您希望单独的实例直接相互通信,则应阅读“两个将军”问题(http://en.wikipedia.org/wiki/Two_Generals%27_Problem),并考虑如何设计非阻塞对象没有种族的会合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM