• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MongoDB Patterns

 
Ranch Hand
Posts: 1907
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome Rick,
One of the pattern/usage of MongoDB given is for Logging. In our system, logs are scattered on various boxes. In middleware too,various components like Adapters,java programs,webservices log to different locations. I belive MongoDB is the right choice for this kind of situation where logs can be consolidated. I wanted to know, if current applications are logging to files, how can that be changed to log to MongoDB ? We use proprietory software where default logging/exceptions are done to files.
Inbuilt gepspatial indexing is the main feature of MongoDB.Is there any advantage of using this over location based services provided by Microsoft/Yahoo! etc?
 
author
Posts: 17
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have two basic options for logging to MongoDB. One is to modify your code to log to MongoDB. Another option is to have a separate process that runs periodically (perhaps at log rotation time) to aggregate the log files into MongoDB. The second approach has the advantage of not requiring any changes to your existing applications, but it does mean that the log data in MongoDB will be somewhat out-of-date.

As for geospatial indexing, I'm not sure of anything that Microsoft/Yahoo may have, so I'll constrain my comments to what MongoDB does. MongoDB does not contain any map data (unless you put some in). The geospatial indexing in MongoDB allows you to store geospatial coordinates (longitude and latitude) for different objects and then execute queries like "find objects in a certain collection, sorted by how close they are to a certain point" or "find all the objects with coordinates that fall within a particular circle" -- things like that.

I hope that helps!
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arjun,

What is the rationale for logging to mongodb ? Is it the amount of data or unstructed data.
 
Arjun Shastry
Ranch Hand
Posts: 1907
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amount of data and speed. Capping concept in MongoDB makes sure servers don't run out of memory. MongoDB i guess faster in reading and writing the data than RDBMS. MongoDriver be default won't wait for write to complete on server.In such case, there may be chance of losing the data incase of failure but thats ok for us.Even if you lose 10 logs out of 10,0000, it won't be much problem.
 
Arjun Shastry
Ranch Hand
Posts: 1907
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rick Copeland wrote:You have two basic options for logging to MongoDB. One is to modify your code to log to MongoDB. Another option is to have a separate process that runs periodically (perhaps at log rotation time) to aggregate the log files into MongoDB. The second approach has the advantage of not requiring any changes to your existing applications, but it does mean that the log data in MongoDB will be somewhat out-of-date.

As for geospatial indexing, I'm not sure of anything that Microsoft/Yahoo may have, so I'll constrain my comments to what MongoDB does. MongoDB does not contain any map data (unless you put some in). The geospatial indexing in MongoDB allows you to store geospatial coordinates (longitude and latitude) for different objects and then execute queries like "find objects in a certain collection, sorted by how close they are to a certain point" or "find all the objects with coordinates that fall within a particular circle" -- things like that.

I hope that helps!


Thanks Rick.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok cool. Also i think mongo db does not support ACID properties of transactions, this may speed up db operations
 
Rick Copeland
author
Posts: 17
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep bhatt wrote:ok cool. Also i think mongo db does not support ACID properties of transactions, this may speed up db operations



This is true; MongoDB performs atomic operations, but they are limited to a single document.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh. so mongodb cannot be used in transactional applications like banking.
 
Rick Copeland
author
Posts: 17
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the question of whether you really need transactions in banking is actually an interesting one... generally, banks do not use ACID transactions for everything; they instead use methods to bound the risks of inconsistency and perform periodic reconciliation of their legers. For instance, it's important to a bank that you be able to withdraw funds from an ATM even if that ATM cannot connect to the server, so they typically put a limit of $500 or so on withdrawals from an ATM. So it's possible to overdraw an account, but not by much.

My book has a specific example in the ecommerce chapter describing how you can implement transaction-like guarantees (in this case, for inventory management) using a technique that I call optimistic update with compensation.

If you really need ACID transactions, you can actually build a 2-phase commit structure atop MongoDB collections; I show how to this in chapter 3, IIRC. I will warn you, however, that it's really easy to forget an edge case when you're building something like this, so if you can restrict your atomic updates to a single document, you'll be much less likely to make a mistake.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic