5

I am building an ASP.Net web application and want to access data from MongoDB (remotely hosted). Any of my documents looks like this (have ensured index on Utc field);

{ 
   "_id" : { "$oid" : "509501393e8785025c10bc21" }, 
   "Index" : 1,
   "Url" : "http:...", 
   "CameraId" : 123,  
   "Utc" : { "$date" : 1351955858006 } 
}

Considering the performance on user end, I want to fetch this data at max speed. One option that i have tried is calling a local Web Service via JSON on Page.aspx which uses MongoDB C# driver to query documents between two Dates (Utc). That works but seems like using web service adds some extra milliseconds in request/response cycle (request for single document using db.foo.findOne() is served in 1.3 seconds on average). Average number of documents in that collection is 50,000 which will increase up-to 30,00,000.

My questions are:

  1. Am i right in saying that using web services adds some delay (millisecs) in request/response cycle ? (because MongoDB actually takes few milliseconds to complete the query)
  2. Second Option is to use MongoDB's HTTP / REST Interface. That way i might avoid web services and directly query MongoDB. Here i need your opinion on,
    • Is there a way to query MongoDB between two Dates using HTTP/REST ?,
    • Is there a way to query MongoDB with '>' and '<' conditions using HTTP/REST ?,
    • How does it seem, accessing DB directly on Page.aspx with security point of view ?
  3. Any other querying alternative OR optimizations for above schema?

My related question is here.

Regards.

2
  • why would you not use the C# driver for MongoDB and query for data directly? Commented Nov 4, 2012 at 5:36
  • As I said earlier, currently i am using C# driver and querying MongoDB directly, but the code using C# driver statements is written in a web method which is called from Page.aspx. I need to know if you have tried MongoDB's HTTP/REST interface and can tell the performance results for comparison with C# driver. Commented Nov 4, 2012 at 7:57

1 Answer 1

5

MongoDB's native HTTP interface is not built for querying. You should continue to do what you are doing. In addition, your MongoDB servers should not be exposed publicly for security purposes and you should always go through a middle tier as you are currently doing.

Sign up to request clarification or add additional context in comments.

3 Comments

Still, i wish some REST-based (token-authenticated) way to query MongoDB, like CouchDB.
10gen has taken a different point of view. Instead of building a single ubiquitous client for "all languages", it has decided to build specific APIs fore each language/framework so that integration with MongoDB feels natural. That being said, it is possible to build a layer on top of one of these drivers to provide a RESTful interface. For instance, while I don't feel it's ready for production yet, I have implemented an OData provider on top of the .NET driver. OData is a RESTful protocol. github.com/craiggwilson/mongo-dotnet-odata
Hmm. Do they have a specific API for curl? Please don't say "The simple REST API" because that is too incomplete and buggy to count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.