Reputation: 1840
I'm using twisted to get messages from internet connected sensors in order to store it to a db.
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...
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...
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
Upvotes: 3
Views: 1538
Reputation: 31641
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.
How you deal with this depends on your workload:
Upvotes: 3
Reputation: 48335
When you get a message, do two things:
You don't need a message queue, multiple processes, IPC, or any of those things. For example:
def messageReceived(self, message):
self.checkForAlerts(message).addCallbacks(self.maybeAlert, log.err)
self.saveMessageToDatabase(message).addErrback(log.err)
Upvotes: 1