FAQ
Hi. I have a single instance mongodb server which handles a lot of small geo data elements for up to 10-30k users

I have a users collection with documents for each user, each which have an embedded array where my app inserts one element each second when users are logged in. In the same insert operation I increment two values in the users document. I have no clue as of yet how many users will be on the site simultaneously.

The array elements is 2D position with a number state and timestamp: { pos [33,55], s: 1, ts: new Date }

The first insertions goes really fast but later on when the array reaches a size around 100-300k items it takes around ~2 up to 13 seconds to insert an new element using $addToSet or $push.

I had at first a index on pos (geo2D) and removed it to speed up the inserts. but it didn't help much. As of now I have no indexes on the arrays or the users (only 5 test users as of now)

Should I use a separate collection for each users geodata in separate collections || embedded documents or have ageodata collection with user id embedded in each geodata element?

Capped collections?

The HW is a quadcore xeon with 4GB RAM running Úbuntu server. And I use the ruby-mongodb-driver for talking to the db.

Thanks!

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user+unsubscribe@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Search Discussions

  • William Z at Aug 24, 2012 at 10:06 pm
    Hi there!

    You're correct: MongoDB inserts will slow down considerably when the number
    of array elements is large. Best Practice calls for keeping the number of
    array elements below a few hundred.

    Given your requirements, I think you should probably use a 'bucketed'
    approach for your geo data elements.

    Here are some examples of using the 'bucketed' approach in a MongoDB schema
    design:

    -
    https://openshift.redhat.com/community/blogs/designing-mongodb-schemas-with-embedded-non-embedded-and-bucket-structures
    -
    http://docs.mongodb.org/manual/use-cases/storing-comments/#hybrid-schema-design
    -
    http://www.10gen.com/presentations/MongoNYC-2012/Building-a-MongoDB-Power-Chat-Server
    (Video 3)

    Let me know if you have any questions.

    -William

    On Friday, August 24, 2012 2:02:03 AM UTC-7, zyk wrote:

    Hi. I have a single instance mongodb server which handles a lot of small
    geo data elements for up to 10-30k users

    I have a users collection with documents for each user, each which have an
    embedded array where my app inserts one element each second when users are
    logged in. In the same insert operation I increment two values in the users
    document. I have no clue as of yet how many users will be on the site
    simultaneously.

    The array elements is 2D position with a number state and timestamp: { pos
    [33,55], s: 1, ts: new Date }

    The first insertions goes really fast but later on when the array reaches
    a size around 100-300k items it takes around ~2 up to 13 seconds to insert
    an new element using $addToSet or $push.

    I had at first a index on pos (geo2D) and removed it to speed up the
    inserts. but it didn't help much. As of now I have no indexes on the arrays
    or the users (only 5 test users as of now)

    Should I use a separate collection for each users geodata in separate
    collections || embedded documents or have ageodata collection with user id
    embedded in each geodata element?

    Capped collections?

    The HW is a quadcore xeon with 4GB RAM running Úbuntu server. And I use
    the ruby-mongodb-driver for talking to the db.

    Thanks!
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmongodb-user @
categoriesmongodb
postedAug 24, '12 at 10:07a
activeAug 24, '12 at 10:06p
posts2
users2
websitemongodb.org
irc#mongodb

2 users in discussion

William Z: 1 post Zyk: 1 post

People

Translate

site design / logo © 2018 Grokbase