r/cpp • u/rish2050 • Dec 27 '22
MongoDB Product Manager here to chat about Databases
Hi! This is Rishabh, recently joined the MongoDB Product team, focussing on drivers for C/C++.
I would love to know your experience with database(s) while writing C++ applications:
How are you using databases in the applications you build?
What has been the experience like?
Did you enjoy/miss anything as a C++ developer?
What resources are you using to get started or to seek assistance?
Any other feedback would be super valuable. Any MongoDB specific feedback would be bonus!
Thanks in advance!
2
u/jgaa_from_north Dec 31 '22
I have not used MongoDB with C++.
I usually use boost.asio as the IO engine and thread-pool in my C++ server applications. The first thing I look for when I use an external service is a library/driver that supports boost.asio composed operations. That makes the library usable with stackfull/stackless/C++20 coroutines, callbacks and futures, so it gives me a lot of flexibility out of the box.
1
u/rish2050 Jan 03 '23
Thanks u/jgaa_from_north for the tip! Would you know if this is a standard industry practice?
1
17
u/_software_engineer Dec 28 '22
Ignore the trolls. I have no Mongo experience but asking the community for feedback like this is a good idea and something you should continue to do. Hopefully someone can give you useful feedback.
1
u/jonesmz Dec 31 '22 edited Dec 31 '22
When I've used postgresql via c++, my largest complaint was the lack of pipelining in the network protocol, so the wrapper libraries had no way to provide this feature.
What I mean here is that I had a usecase where I was receiving data from client devices, and needed to stick that data into the db. My service would need to wait for the insert operation to complete before beginning the next insert.
In my situation, I observed many hundreds of data points waiting to be inserted even with a fairly small number of client devices.
I ended up throwing my hands up in frustration and providing my own hack-job of "pipelining" by creating a stored procedure that could accept multiple rows of data in a batch. This allowed me to send all the data that my service had accumulated by that point as soon as the next insert operation could begin.
So the take away here is to expose the full asynchrony that your product can support natively at the protocol level, so that all client libraries can take advantage of it.
The library that I ultimately used with Yandex's OZO library.
Mandatory features for any future DB work I do:
boost asio support, either baked into the core of your client library, or with a suitably seemless wrapper layer.
support for serializing / deserializing to native c++ types. This includes custom structs and classes, not just std:: namespace.
fallback of allowing for direct access to the native buffer of bytes that come over the network, both reading and writing.
all operations should be cancelable, at least until the point it leaves the network stack. But all operations should be cancelable until the transaction finalizes anyway, so that shouldnt be a problem.
support for notifications of data being modified on the server so that a client can wake up and do work. Best / better is for any such notifications to also indicate the primary key of what's being modified. Custom logic that runs server side to let the client customize how / when / what its notified would be ideal
While Yandex's OZO library isn't perfect, and can't perfectly handle all of the things I list above, its pretty damn amazing for what it wants to implement. You'd be well served to study it, or even fork it and modify it to work with MongoDB.
1
u/rish2050 Jan 03 '23
u/jonesmz Appreciate the detailed feedback. This is super helpful! I need to do some research here, and may get back to you with some follow up questions. Thanks!
1
u/Occase Boost.Redis Jan 03 '23
That's a great list of features. In case you ever need Redis have a look at https://github.com/mzimbres/aedis. It implements all points you listed.
1
u/lucidguppy Jan 02 '23
What happened with mangrove?
https://github.com/mongodb-labs/mangrove
Every project that a company drops is a big X on adopting something in the future.
1
u/rish2050 Jan 03 '23
Hi u/lucidguppy, it was an experimental project from MongoDB Labs, developed by an intern as a summer project. Unfortunately, it couldn't get enough traction at that time to be a fully funded product.
0
Dec 28 '22
[deleted]
1
u/rish2050 Dec 28 '22
Thanks for your inputs, u/Drunk-sysadmin.
Would you mind sharing what kind of apps that you are building or what kind of environment constraints you need to adhere to? Running everything locally would be relatively faster but I'd like to understand what makes a cloud app "slow af" in your case.Btw, MongoDB does support ACID transactions (since v4.0).
Some references:
2
Dec 30 '22
[removed] — view removed comment
2
u/rish2050 Jan 03 '23
Thanks u/--prism, could you please help me understand the last line correctly? I am not sure if I get it right.
4
u/Civil-Cake7573 Dec 28 '22
Maybe not matching your original topic but I'm in database research, partly focusing on query compilation (SQL to LLVM or direct assembly). Tbh, I don't know if MongoDB is using query compilation. If not, what so you think about that?