tailable cursors / long-polling

135 views
Skip to first unread message

John Stanford

unread,
Dec 20, 2010, 11:23:03 AM12/20/10
to mongod...@googlegroups.com
Hi,

I'm relatively new to Mongo, and so far really like my experiences.  I stumbled across tailable cursors and immediately thought they would be very useful for long-polling situations where I want to catch adds/updates and push them to the UI.  Then I noticed that the collection of interest needs to be capped.  This raised a couple questions for me:


1.  Why limit tailable cursors to capped collections?
2.  Should I use capped collections with huge limits as my primary object storage even though it would force me to "cap" my application at some point OR
3.  Should I use uncapped collections for my primary storage, and a "shadow" capped collection with a reasonable size to support long polling (duplicate writes)

I'm curious to hear if/how others have leveraged tailable cursors for long-polling support, or other solutions that have proved efficient.

Thanks,
John

Eliot Horowitz

unread,
Dec 20, 2010, 4:24:34 PM12/20/10
to mongod...@googlegroups.com
Tailable cursors are used internally for replication, and were
designed specifically for that, and therefore capped collections.
It would be possible to make it used for anything, just hasn't been a priority.

I definitely wouldn't recommend using capped for your main storage.

With regards to what to do, a little more color on exactly your needs
would be helpful.

Dual writing wouldn't be a bad idea.

> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
>

John Stanford

unread,
Dec 20, 2010, 5:05:58 PM12/20/10
to mongod...@googlegroups.com
Hi Eliot,

What I'm trying to accomplish is to have financial transactions come in
via several sources and get updated on the user's screen without the
client constantly polling. So, I've been using Scala, Vaadin, and ICEpush
to implement long polling. I was going to use a tailable cursor to detect
new transactions and push them via ICEpush to the client when they show
up. It sounds like I can write each transaction to the permanent
(uncapped) collection and to a capped collection that supports a tailable
cursor.

Thanks,
John

Eliot Horowitz

unread,
Dec 20, 2010, 5:10:14 PM12/20/10
to mongod...@googlegroups.com
That makes sense.
Let us know how it goes.

John Stanford

unread,
Dec 20, 2010, 5:39:54 PM12/20/10
to mongod...@googlegroups.com
Sure. Spare time project, so going slow :-)

John

Reply all
Reply to author
Forward
0 new messages