Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb - use tailable cursors instead of polling #33

Closed
gregwebs opened this issue Nov 3, 2011 · 6 comments
Closed

mongodb - use tailable cursors instead of polling #33

gregwebs opened this issue Nov 3, 2011 · 6 comments

Comments

@gregwebs
Copy link

gregwebs commented Nov 3, 2011

  • [http://www.captaincodeman.com/2011/05/28/simple-service-bus-message-queue-mongodb/](C# demonstration code)
  • [https://gist.github.com/665978](Ruby tailable cursor code).
@jnunemaker
Copy link
Collaborator

Correct me if I'm wrong, but wouldn't that limit the number of workers to one per queue or cursor? Also, there would need to be some work involved to make sure you didn't lose any jobs if the cursor closed I'm thinking.

On Thursday, November 3, 2011 at 1:39 PM, Greg Weber wrote:

  • [http://www.captaincodeman.com/2011/05/28/simple-service-bus-message-queue-mongodb/](C# demonstration code)
  • [https://gist.github.com/665978](Ruby tailable cursor code).

Reply to this email directly or view it on GitHub:
#33

@gregwebs
Copy link
Author

gregwebs commented Nov 3, 2011

Yes, you will still need to modify members of the collection to mark them
as finished so you know how to recover. This could be done by unsetting a
created_at field. You probably do only want to have one tailing cursor, but
that process could broker the queue to any number of consumers.
.
On Thu, Nov 3, 2011 at 11:42 AM, John Nunemaker <
reply@reply.github.com>wrote:

Correct me if I'm wrong, but wouldn't that limit the number of workers to
one per queue or cursor? Also, there would need to be some work involved to
make sure you didn't lose any jobs if the cursor closed I'm thinking.

On Thursday, November 3, 2011 at 1:39 PM, Greg Weber wrote:

  • [
    http://www.captaincodeman.com/2011/05/28/simple-service-bus-message-queue-mongodb/](C#demonstration code)
  • [https://gist.github.com/665978](Ruby tailable cursor code).

Reply to this email directly or view it on GitHub:
#33


Reply to this email directly or view it on GitHub:
#33 (comment)

@bkeepers
Copy link
Owner

bkeepers commented Nov 3, 2011

That's a really interesting idea. It would be great if you could use a tailable cursor with the findAndModify command.

Any idea how we could do this without creating contention between workers?

@gregwebs
Copy link
Author

gregwebs commented Nov 3, 2011

You still have to use findAndModify to flag a document as finished
processing. Using the broker technique means only the broker accesses the
database, so there is no database contention between workers and the broker
can also supervise workers.

Other articles on this approach:

  • a benchmark demonstrating very good performance [1]
  • others using findAndModify instead of RabbitMQ [2]
  • a Lift chat app using tailable cursors [3]

[1] http://www.shtylman.com/archives/217
[2] http://blog.boxedice.com/2011/09/28/replacing-rabbitmq-with-mongodb/
[3] http://amoss.me/lift-chat-with-mongodb-tailable-cursors

On Thu, Nov 3, 2011 at 1:38 PM, Brandon Keepers <
reply@reply.github.com>wrote:

That's a really interesting idea. It would be great if you could use a
tailable cursor with the findAndModify command.

Any idea how we could do this without creating contention between workers?


Reply to this email directly or view it on GitHub:
#33 (comment)

@mattparlane
Copy link

Hi all... I thought I'd drop by to say I've logged a feature request to have findAndModify return tailable cursors:

https://jira.mongodb.org/browse/SERVER-11753

This would allow blocking reads instead of polling (via tailable cursors), plus the guarantee that only one consumer would get any given job (via findAndModify). Please vote for it if you're interested in this functionality.

@jnunemaker
Copy link
Collaborator

If anyone wants to tackle this feel free to create a new backend like tailable_mongo or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants