[英]Architecture approach with IPC, Twisted or ZeroMQ?
I'm using twisted to get messages from internet connected sensors in order to store it to a db. 我正在使用twisted来从互联网连接的传感器获取消息,以便将其存储到数据库中。
I want to check these messages without interfere these process,because I need compare every message with some base values at db, if some is matched I need trigger an alert for this, and the idea is not block any process... 我想在不干扰这些过程的情况下检查这些消息,因为我需要在db处比较每条消息和一些基本值,如果有一些匹配,我需要触发一个警报,并且这个想法不会阻止任何进程......
My Idea is create a new process to check and alert, but I need after the first process store the message, it will send the message to the new process in order to check and alert if is required. 我的想法是创建一个新的流程来检查和提醒,但我需要在第一个流程存储消息后,它会将消息发送到新流程,以便检查并提醒是否需要。
I'm need IPC for this, and I was thinking to use ZeroMQ, but also twisted have a approach to work with IPC, I think if I use ZeroMQ, but maybe it will be self-defeating... 我需要IPC才能做到这一点,而我正在考虑使用ZeroMQ,但也有扭曲的方法与IPC合作,我想如果我使用ZeroMQ,但也许它会弄巧成拙......
What think you about my approach? 你怎么看待我的做法? Maybe I'm completely wrong at all?
也许我完全错了?
Any advice are welcome.. Thanks 欢迎任何建议..谢谢
PD:This Process will run at a dedicated server, with a expected load of 6000 msg/hour of 1Kb each one PD:此进程将在专用服务器上运行,预期负载为6000 msg /小时,每个1Kb
All of these approaches are possible. 所有这些方法都是可能的。 I can only speak abstractly because I don't know the precise contours of your application.
我只能抽象地说话,因为我不知道你的应用程序的精确轮廓。
If you already have a working application but it just isn't fast enough to handle the number of messages you throw at it, then identify the bottleneck. 如果您已经有一个正在运行的应用程序,但它不够快,无法处理您抛出的消息数,那么就找出瓶颈。 The two likely causes of your holdup are DB access or alert-triggering because either one of these are probably synchronous IO operations.
您持有的两个可能原因是数据库访问或警报触发,因为其中任何一个都可能是同步IO操作。
How you deal with this depends on your workload: 您如何处理这取决于您的工作量:
When you get a message, do two things: 收到消息后,请执行以下两项操作:
You don't need a message queue, multiple processes, IPC, or any of those things. 您不需要消息队列,多个进程,IPC或任何这些东西。 For example:
例如:
def messageReceived(self, message):
self.checkForAlerts(message).addCallbacks(self.maybeAlert, log.err)
self.saveMessageToDatabase(message).addErrback(log.err)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.