My question - is there a way to read and write to the MongoDB simultaneously? Or make MongoDB reader greedy?
I have a web application that uses MongoDB for the database. In my application, I have a Serial Event that I am listening for. On this Serial Event, I create a new thread to deal with the event. In the thread, the string from serial is parsed and an object is created then written to the mongo database (a new document is created and added into a specific collection).
However, while this serial event is occurring, I am trying to also read from the database and update a graph to show the new incoming data from this collection. The problem is that because MongoDB is writer greedy (see http://docs.mongodb.org/manual/faq/concurrency/), it appears that the reads are never being allowed to occur.
My serial events are happening about 2/3 times a second. And my reading is happening about 2 times a second as well. The data needs to stay written to a database so that all clients can have access to it, not just the client receiving the Serial event.
So my question is, is there a way to allow my reads through? Can I change the lock on MongoDB to be reader greedy? Or is there a way I can read and write at the same time without compromising speed? Is sharding a way around this problem (I do not know a lot about sharding so not sure if this would fix my problem)?
If you want any code posted up let me know! Any comments or workarounds would be greatly appreciated!