跨进程(和机器)同步(信号量) [英] Cross Process (and machine) Synchronization (Semaphores)

查看:45
本文介绍了跨进程(和机器)同步(信号量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WCF 应用程序必须调用一个没有任何并发​​检查的服务.这是由第三方创建的服务,可能无法让他们添加并发检查.

My WCF application has to call a service that does not have any concurrency checking in it. It is a service created by a third party and getting them to add concurrency checking may not be possible.

我可以确保调用第三方服务的唯一方法是通过我的 WCF 应用程序.所以我正在考虑在我的代码中加入并发检查.

I can ensure that the only way to call the third party service is via my WCF application. So I am considering putting concurrency checking in my code.

为此,我将使用唯一描述正在修改的数据的标识符.这个想法是,如果对服务的一次调用正在修改与标识符相关的数据,那么对该标识符的其他调用将需要等到它完成.

To do this, I will use an identifier that uniquely describes the data being modified. The idea is that if one call to the service is modifying data related to the identifier, then other calls for that identifier will need to wait till it is done.

我的 WCF 服务是负载平衡的.我最多可以同时运行 16 个实例,它们都在不同的虚拟机上.

My WCF Service is load balanced. I can have as many as 16 instances running at the same time, all on different virtual machines.

因此,大多数处理同步的 .NET 类都假定共享内存空间.

So most of the .NET classes that deal with synchronization assume a shared memory space.

是否有标准的、最佳实践"类型的方法来为服务的负载平衡实例进行同步?

Are there standard, "best practice" type ways to do synchronization for load balanced instances of services?

我曾考虑使用数据库表 (SQL Server) 来尝试管理此问题,但从架构的角度来看,将我的持久层用于此目的似乎是错误的.我希望有另一个解决方案.

I have considered using a database table (SQL Server) to try to manage this, but seems wrong from an architectural point of view to use my persistence layer for this purpose. I am hoping for another solution.

我如何在机器之间进行同步(锁、互斥、信号量等)?(最好不使用数据库表来管理它.)

How do I do synchronization (Locks, Mutex, Semaphore, etc) across machines? (Preferably without using database tables to manage it.)

推荐答案

使用 分布式锁管理器 根据您创建的标识符锁定资源修改.

Use a Distributed lock manager to lock resource modification based on the identifier you created.

您可以使用的一些 DLM 包括:

Some of DLM's you can use are:

这篇关于跨进程(和机器)同步(信号量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆