Closed ghost closed 10 years ago
I think one of imap-listener should be active. Switch to another instance when active is deactivated. Establish some communications between imap-listeners to determine which should handle new message from imap server.
Do you really want multiple instances of mail listener? Are the volumes so high?
Anyways, I see the problem. Below are few approaches which you can use:
1) Use redis as load balancer Maintain a list of mails to be processed in redis. Use BRPOPLPUSH to load balance between instances of mail-listener. Use LREM to avoid duplicates in the list of mails.
2) Use some database: Maintain a list of mails to be processed in db. Query db periodically and process them one by one. Change the status of processed mails or delete the mail from the list.
Let me know how you go about this.
closing for inactivity.
This is off topic but still little help would be appreciated.
We are running multiple Beanstalk instances of our app and the imap listener(of all instances) fire when a new mail arrives.
This is resulting in a race condition.
Ideally, we want load balancing to get in action.
Any thoughts ?