[CXX-344] Asynchronous (event driven) Driver Created: 18/Sep/14 Updated: 08/Jan/24 Resolved: 09/Sep/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Pieter Jordaan | Assignee: | David Golden |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | async, concurrency, driver, events, performance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
The biggest drawback in the client driver currently is that all the API functions are blocking. Being able to pass a callback function to functions such as getLastError will not only lead to better design, but also a huge performance and concurrency increase. The low level sockets are as far as I can deduce already asynchronous. It should be possible to build from that into an asynchronous event driven driver. Since boost is already employed I recommend looking at asio and bind. |
| Comments |
| Comment by David Golden [ 09/Sep/16 ] |
|
I'm doing a review of long-open tickets to clean up our backlog. Given the current design wrapping the C driver, we won't be implementing async support in the C++11 driver. I'll raise the general issue with our product management team for longer-term planning. |
| Comment by Pieter Jordaan [ 02/Jan/16 ] |
|
I agree that this can be done with threads at the application level, however it would be much more efficient when done at socket level in the driver itself. |
| Comment by Alex Hultman [ 02/Jan/16 ] |
|
I would like to see this as well. But just like Andrew said, it doesn't really matter that much since you can simulate this with threads. It's a completely different thing dealing with 100k connections but since you typically have a very limited amount of connections to mongod, it's no problem at all to use threads. Don't buy into the hype of async without thinking about what you really need. I used this blocking driver at my last workplace and it performed far beyond any JavaScript async counterpart when paired with efficient threading. |
| Comment by Andrew Morrow (Inactive) [ 02/Mar/15 ] |
|
Thanks for getting back to us. I'm happy to re-open this ticket, thought I'd like to provide some clarification on why I don't expect it to be resolved in the near term. The first important thing to consider is that the master branch driver is really a thin shell around the C driver, and we hope to retain this model. The C driver does not currently expose an asynchronous interface. So designing and implementing an async API for the C driver is a prerequisite to offering an asynchronous interface for the C++ driver. I recommend coordinating with mira.carey@mongodb.com and jesse to either file a CDRIVER ticket requesting this, or to follow an existing ticket, if one already exists. The second consideration is that it was unclear to the developers of the C++11 driver what direction the ISO C++ committee was taking networking and async support post C++14. We are very interested in seeing what emerges from the TS process, and felt that it was premature to design a solution before, at the very least, the network TS arrives. Overall, we felt that delaying the C++11 driver further in an effort to wait out the above issues would have been a mistake. Finally, I think it is very likely possible to effectively simulate an async driver by placing a thread pool and work queue of closures in front of the driver. If you are interested in pursuing this angle we would be happy to provide sample code, most likely as an additional mongocxx example. Thanks, |
| Comment by Pieter Jordaan [ 02/Mar/15 ] |
|
Will you reopen this for the C++11 rewrite master branch? |
| Comment by Adam Midvidy [ 07/Jan/15 ] |
|
At this time we do not plan to make significant changes to the implementation of the legacy driver. |