实现 Azure 流分析作业的异地冗余Achieve geo-redundancy for Azure Stream Analytics jobs

Azure 流分析不提供自动异地故障转移功能,但你可以通过在多个 Azure 区域中部署相同的流分析作业来实现异地冗余。Azure Stream Analytics does not provide automatic geo-failover, but you can achieve geo-redundancy by deploying identical Stream Analytics jobs in multiple Azure regions. 每个作业都会连接到本地输入和本地输出源。Each job connects to a local input and local output sources. 应用程序负责将输入数据发送到两个区域输入并在两个区域输出之间进行协调。It is the responsibility of your application to both send input data into the two regional inputs and reconcile between the two regional outputs. 流分析作业是两个独立的实体。The Stream Analytics jobs are two separate entities.

下图描绘了具有事件中心输入和 Azure 数据库输出的异地冗余流分析作业部署示例。The following diagram depicts a sample geo-redundant Stream Analytics job deployment with Event Hub input and Azure Database output.

异地冗余流分析作业示意图

主要/辅助策略Primary/secondary strategy

应用程序需要对以下情况进行管理:将哪个区域的输出数据库视为主数据库,将哪个区域的输出数据库视为辅助数据库。Your application needs to manage which region's output database is considered the primary and which is considered the secondary. 在主要区域发生故障时,应用程序将切换到辅助数据库,并开始从该数据库读取更新。On a primary region failure, the application switches to the secondary database and starts reading updates from that database. 允许最大限度减少重复读取的实际机制取决于应用程序。The actual mechanism that allows minimizing duplicate reads depends on your application. 可以通过将其他信息写入输出来简化此过程。 You can simplify this process by writing additional information to the output. 例如,可以向每个输出添加时间戳或序列 ID,这样就可以轻松跳过重复行。For example, you can add a timestamp or a sequence ID to each output to make skipping duplicate rows a trivial operation. 主要区域在恢复后会使用类似的机制跟上辅助数据库的进度。Once the primary region is restored, it catches up with the secondary database using similar mechanics.

尽管不同的输入和输出类型允许使用不同的异地复制选项,但是我们建议使用本文所述的模式来实现异地冗余,因为它为事件生产者和事件使用者都提供了灵活性和控制权。Although different input and output types allow for different geo-replication options, we recommend using the pattern outlined in this article to achieve geo-redundancy because it provides flexibility and control for the both event producers and event consumers.

后续步骤Next steps