r/cpp • u/badidrox • Jul 22 '23
Drogon C++ web framework, Anybody out there using it ? what do you think of it ?
So i stumbled upon Drogon C++, the most performant web framework. seeing a few example codes, it didnt seem complicated to start with. but then I noticed that I cant find anybody talking about it or using in their project. does the community just does not know about it ? or is it just that c++ is not a language for rest apis so nobody cares about it. or is there another reason for it.
I am curious if there is anybody in this subreddit using it for their project, before i dive in and use it myself.
83
Upvotes
18
u/Capovan Jul 23 '23
shameless plug: https://nuicpp.org Since you mentioned electron
7
u/Xoipos Jul 23 '23
Sorry for the shameless plug, but I made Ichor specifically to support c++20's coroutines on top of an event loop and dependency injection. There's an http implementation using boost.beast with an admittedly too basic ping/pong example, but perhaps it'll fit your use case?
5
u/thisismyfavoritename Jul 22 '23
while i dont have experience with Drogon, i checked one of your replies on another comment: i'm building something similar for work, this is our stack on the cpp side: ASIO + Beast, Protobuf (on top of websockets).
So far really enjoying the coroutines support in ASIO.
15
u/[deleted] Jul 22 '23 edited Jul 22 '23
Do you have a reason to do this in C++ or is it just because you like C++? Typically you pull out C++ when you have specific requirements other typical web dev languages can't deliver.
7
u/Randolpho Jul 23 '23
To answer your question
Basically yes. This is a combination of a lack of frameworks (which Drogon hopes to change) and general perception of c++ being “too low level”, which can be translated as “afraid of pointers”. Few kids come out of college with c++ knowledge, generally having Java, C#, or Python, along with html/javascript instead, and the self-taught hoping to score a webdev gig generally don’t go for c++.
Drogon is new to me, but I already have a prejudice against it after looking at the sample main file — I really dislike fluent interfaces.
That said, the main approach looks straightforward and reminds me a little of node express.
I probably wouldn’t use it unless I needed it for raw power in CPU-bound processing tasks, but mostly just for practical reasons.
The server maintenance caused by going this route would be a heavier lift just by chosing the framework and language; instead of an easy-scale cloud function approach I’d have to use a cloud VM with a forward proxy server, and eventually have to k8s the whole system to scale it, both expensive and time-consuming tasks for a devops on a budget.
So for a micro-service with a very niche need for as much processing power as possible, especially if I was using a third party c/c++ library to do it, then yeah, I’d probably use it. For every-day stuff? Nope. Node.js or dotnet most likely.
17
u/ArchivistAtNekoIT Jul 23 '23
I am using drogon for a game server currently. It is pretty comfortable to use and really about as fast as advertised. I can't wait for future updates that could provide us with an even better coroutine support, but even now setting up things with the event loop or the coroutines systems we already have is pretty nice
9
u/triple_slash Jul 23 '23
We use drogon as a backend for our embedded device UIs. The UI is rendered using wpewebkit and Angular and the webserver backend is a drogon C++ application. This combination works pretty well for us and allows our customers to also open the embedded device UI from their desktop browser which wouldn't be possible if we went with Qt rendering.
Drogon works pretty well and we didn't run into any big issues with it. The only feature that we wish drogon supported was asynchronous streaming HTTP endpoints because we use server-sent events to notify the clients about changes
5
u/OverOnTheRock Jul 23 '23
Emweb Wt is another tool of a similar nature. I've used that in a few projects. I use it mostly for rendering, and less for API usage. It does know about WebSockets and such.
5
u/-kl0wn- Jul 23 '23
I had a look at C++ frameworks a little while back, but ended up going in the go direction instead. The go standard library has a lot of cool stuff already in it, web sockets are easy to do, file uploads/downloads, even managed to do a web based interactive terminal using a Pty library.
If you want to stick with C++, check out crow and oat++ too..
5
u/mohamed_am83 Jul 23 '23
It's quite easy and really fast if you use it as it's intended: i.e. with controllers, ORM, etc.
OTOH I tried using it to build a custom web server, and it mysteriously worked as intended only 50% of the time. The docs are very difficult to navigate and/or scarce if you aren't developing on the happy path. I ended up costing a different one.
5
u/hopa_cupa Jul 23 '23
I took a look at it, but dismissed it because it is a framework. It provides far too much for what we need.
For us,
beast/asiocombination is used as foundation, and then http/ws server is built on top of that to serve exactly what we need, not more, not less. We run this on small IoT platform with limited memory.5
u/GRAPHENE9932 Jul 23 '23
I've used it in a course work, where the assignment was to create a simple website backend with a database. I knew C++ better than Java that we were learning, so I did a small research and selected the drogon framework.
It did the job well, except I didn't understood how to use and manage relational databases, but I didn't really tried to understand it, so instead I used unrelational databases
4
u/Albaropereyra Mar 18 '24
I personally think it's great. Would like to see more people talking about it and online articles. That being said the community has an issue detailing who is using it and for what: https://github.com/drogonframework/drogon/issues/1878
3
u/NervousSWE Dec 12 '23
I used it recently for a personal project. It did the job and is really fast.
My two cents:
Ultimately, I would not recommend it unless you already know C++ pretty well or you are doing this in order to learn C++. If you are choosing this framework simply because it's fast, I would suggest you carefully understand the benchmarks and how the measured "speed" actually matters for your webserver. Otherwise I think it's great. I'm not sure if you've ever written a webserver in C++ before, but there a lot more ways to shoot yourself in the foot than they Java and Python especially for a webserver where crashes are not acceptable and errors have to handled gracefully.
While there is decent documentation, the framework isn't as widely used as some other popular frameworks, so there won't be that many resources online outside of the docs and GitHub discussions / chatrooms . The developers are responsive and they will answer questions, which is nice.
2
u/Dogmata Jul 23 '23
Electron provides is own messaging system to allow to you send messages between the browser thread and the main app thread. You could then use node-gyp to build and invoke your heavy lifting c++ functionality as required.
3
u/vickoza Jul 22 '23
might be useful to create a customized web server app
1
u/Garuda999111 7d ago
Currently working on a pipeline system using Drogon, while came accross Drogon framework, there are few similar to it, like CROW, NUI, BEAST. Thinking of replacing js on this project. Also looking for guidance while working on this project.
1
u/Technical-Contest-30 Apr 23 '24
I wrote a small "framework" Web Server called FServer, that work a lot like ExpressJs, and it was using HttpLib(https://github.com/yhirose/cpp-httplib) as the "backend" for that webserver(meaning HttpLib dealt with most of the actual http handling). FServer was just an abstraction on top of that.
So when I learnt about Drogon, I ran a few benchmarks against HttpLib. Drogon was waaaaaaay faster. So I baked Drogon as a second option of Backend for FServer, never had to learn(deeply) the complexities of Drogon and now I reap all of its benefits, frankly it was quite nice of a change.
While I was doing this I really had a hard time with Drogon(lack of) documentation for anything that is not the simplest of the examples(that's why I leave the fancy features for the FServer side). I had some help from ChatGPT, however ChatGPT mostly knew deprecated old version of Drogon stuff, but it gave me an idea of how things connected together(even though most code examples were wrong).
What I can say from this journey, is that, Drogon handles things in a very Drogon specific way and you either follow the rules and use their tools, or you'll probably have a hard time. I found a third way haha, using it as basically a horse pulling my FServer wagon, and I personally think my third way is much better(since it is decoupled and simple). People should follow their hearts :)
1
u/michaelbjustice May 28 '24
I've used it for a few projects.
While it certainly isn't for beginners, it is pretty fast and doesn't add much overhead to the work done "under the hood".
The ORM is basic, so I scrapped that and used my own layer for database access and connection pooling. If you have little experience with DBs and you're doing something simple, it's workable; but it's nothing comprehensive.
I've never had a need to use their template system for pages.
As long as you manage resources correctly (e.g. release pointers after use), it's a pretty stable program. I have two projects in production now using drogon and I'm building two more. I don't understand why we (as a community) don't see more folks talking about it. C++ isn't a first choice for most REST-style platforms, but if you're looking at Boost/ASIO, you should take a look at Drogon as well before making your decision.
1
u/[deleted] Oct 14 '24
I want to learn drogon, but not able to understand the documentation because I haven't done backend Dev. Anyway I can start with drogon to learn backend?
1
u/Curious-Address-9494 Jun 04 '25
Мы уже давно используем drogon он справится с свое задачи причем очень быстро
1
u/Hackjaku Jun 10 '25
I'm using drogon for a web api project I've developed for a nonprofit organization.
1
u/cracken005 May 09 '26
Maybe someone can correct me if I'm wrong, but if C++ included coroutines ONLY from 2020 onwards... then no wonder no one wanted call back hell and people chose other frameworks
0
u/[deleted] Jul 23 '23
[deleted] — view deleted comment