PHP 队列故障安全


PHP queue fail safe

目前使用亚马逊的队列服务设置队列系统。现在我正在使用主管来防止工人辞职。

尝试提供一个前端点,该前端点可以接收 500-2K 请求/秒,并且需要通过队列捕获数据。有时队列服务[基于 https] 会出现故障,我目前正在将 beanstalkd 作为备份队列运行,该队列获取相同的数据并发送给单独的工作线程组并将该数据存储在单独的数据库中,但具有与主数据库相同的表结构。

我的想法是,我会从备份中获取数据,并将其与预期的实际数据进行比较并对其进行审核,任何差异都将被报告并可能添加到预期的数据集中。

这似乎是解决这个问题的实用方法吗,因为我试图确保我们捕获 99.99% 的数据。

下面的小"演示"可以帮助您了解情况。

Endpoint A -- collects data(
    Queue1[amazon type queue]
    Queue2[beanstalkd]
)
Queue1 Worker sends data to DB1[used for reports]
Queue2 Worker sends data to DB2[storage --expect to have all data]
Audit Process compares data from DB2 to DB1 and reports the differences
If differences captured, tries to add them to DB1

决定采纳 N.B 的意见并应用不同的模型。我有一个主要队列服务和一个辅助队列服务。如果第一个发送了空或错误的 http 响应,我会将消息发送到备份队列。队列工作线程将从两个源拉取并适当地运行它们。

这是它最终结果的小图,所以你可以看到最初的想法和最终想法之间的区别......

Endpoint A -- collects data(
    Queue1[amazon type queue]
    Queue2[amazon2 type queue]
)
Queue1 Worker sends data to DB1[used for reports]
If Queue1 fails, it auto sends data to Queue2, 
If Queue2 fails, it stores in database for later retrieval