如何在 Azure 多实例(规模集)虚拟机中存储临时数据?

How to store temporary data in an Azure multi-instance (scale set) virtual machine?

我们开发了一个服务器服务,(简而言之)支持两个设备之间的通信。我们想利用 Azure 规模集(多实例 VM)提供的可伸缩性,但我们不确定如何在每个实例之间共享内存。

我们的服务基本上将临时数据存储在本地虚拟机中,这些数据被读取、修改并发送到连接到该服务器的设备。

如果这些数据本地存储在其中一个实例中,则其他实例无法访问并且没有相同的信息。正确吗?

如果其中一个设备开始向服务器发出某些请求,则要处理该请求的实例将不会始终相同,因此最后的数据会在实例之间传播。

所以问题可能是,如何在 Azure 实例之间共享内存?

谢谢

您可以使用 Service Fabric and take advantage of Reliable Collections 让您的状态自动复制到所有实例。

来自https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-reliable-collections/

The classes in the Microsoft.ServiceFabric.Data.Collections namespace provide a set of out-of-the-box collections that automatically make your state highly available. Developers need to program only to the Reliable Collection APIs and let Reliable Collections manage the replicated and local state.

The key difference between Reliable Collections and other high-availability technologies (such as Redis, Azure Table service, and Azure Queue service) is that the state is kept locally in the service instance while also being made highly available.

Reliable Collections can be thought of as the natural evolution of the System.Collections classes: a new set of collections that are designed for the cloud and multi-computer applications without increasing complexity for the developer. As such, Reliable Collections are:

  • Replicated: State changes are replicated for high availability.
  • Persisted: Data is persisted to disk for durability against large-scale outages (for example, a datacenter power outage).
  • Asynchronous: APIs are asynchronous to ensure that threads are not blocked when incurring IO.
  • Transactional: APIs utilize the abstraction of transactions so you can manage multiple Reliable Collections within a service easily.

使用可靠的集合 -
https://azure.microsoft.com/en-us/documentation/articles/service-fabric-work-with-reliable-collections/

根据您要共享的数据类型和延迟的重要性,以及 ServiceFabric(低延迟但您需要 re-architect/re-build 位的解决方案),您可以查看共享的后台end repository - Redis Cache 是分布式缓存的理想选择; SQL Azure 如果你想使用关系数据库来存储数据;存储 queue/blob 存储 - 或存储帐户中的文件存储(这允许您只从两个 vm 实例写入已安装的网络驱动器)。 DocumentDB 是另一种选择,适合存储 JSON 数据。