-
Notifications
You must be signed in to change notification settings - Fork 1
Foreword
MongoAsync is a scala driver that provides fully non-blocking and asynchronous I/O operations.
It aims to provide an easy way to build heavy scalable, streaming capable MongoDB-based applications.
MongoAsync is build with the following principles in mind:
- no database operation should be blocking
- streaming I/O everywhere it is meaningful
- simple and extensible API
MongoAsync is built on three main libraries:
- Netty as a NIO framework
- Akka for the Future and Actor API
- Play Iteratees
The heart of MongoAsync is an Akka actor: MongoDBSystem. MongoConnection is in fact an instance that sends messages to a MongoDBSystem actor reference. This actor creates the actual connections, routes the messages, deals with errors. Moreover, it maintains the state of the Replica Set, and the authentication status.
One of the MongoDBSystem actor's missions is to choose which node will be queried. If the operation does not require to run on a primary, and if it has the SlaveOk flag set to true, a secondary node will be chosen. The current algorithm for picking a node is round-robin.
Each node has a fixed number of open connections. Each time a message needs to be sent to a particular node, the MongoDBSystem actor selects a connection with the round-robin algorithm.