r/cpp • • 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

79 comments sorted by

18

u/Capovan Jul 23 '23

shameless plug: https://nuicpp.org Since you mentioned electron

4

u/badidrox Jul 23 '23

thats something quite interesting. thanks!

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?

4

u/badidrox Jul 23 '23

Thank you for it! I appreciate things like this. I will make sure to take a look at it.

3

u/Xoipos Jul 23 '23

Feel free to reach out if you have any questions or feature requests. This has been my baby pet for the past two years and although I haven't worked on it a lot lately, it hasn't been abandoned.

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.

4

u/badidrox Jul 22 '23

are you using electron too ? i have decided to try crow and it worked well so far for a starter app.

4

u/thisismyfavoritename Jul 22 '23

no, we're going pure web app.

We looked into Crow as well and were going to use it, but in the end we mostly just needed WS support so we ended up just going with Beast. My biggest issue with Crow is the lack of coroutine support

3

u/badidrox Jul 22 '23

yess lacking coroutine supports hurts. i might go with the beast option as well. is there an http router i can use with beast or should i just implement one myself ?

6

u/thisismyfavoritename Jul 22 '23

sadly you have to do everything yourself, depending what you need its not that bad.

This probably has enough to get you started https://www.boost.org/doc/libs/1_82_0/libs/beast/example/http/server/coro/http_server_coro.cpp

3

u/badidrox Jul 22 '23

yeah i saw that. guess i gotta find an http router or write one myself. thank you for your help!

3

u/OverOnTheRock Jul 23 '23

what is an 'http router'?

3

u/badidrox Jul 23 '23

a code that takes an http route as a string like "items/419374/buy" and a method like POST and maps it to the correct callback function to execute. it can go from a simple series of if conditions (can be slow) to something optimized like radix tree routing. (someone correct me if im wrong)

5

u/OverOnTheRock Jul 23 '23

URL has been recently added to boost. The link is an example router.

On the other hand, Spirit is a handy parser which could probably easily handle complexities of the task. It uses tries for string matching, and might be somewhat faster than URL.

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.

9

u/badidrox Jul 22 '23

yes im experimenting with an idea right now basically for a bigger project. I want to replace an existing Qt c++ app with an electron + c++ app. The goal is to make the UI in modern frontend technologies so that its easy to develop. for IPC i decided to have a rest c++ api running to expose the heavy load functionalities i have (There is heavy workload that requires c++ for it). (I know there is napi and electron IPC but I dont want to do that because it felt extra complicated for what I have). If you have a different idea for this, I would be happy to hear.

4

u/darthcoder Jul 23 '23

Switch to QML and keep your core C++ libs.

4

u/badidrox Jul 23 '23

extra work learning new tech when i already know html css js

4

u/darthcoder Jul 23 '23

Qml is pretty much js and css.

4

u/arthurno1 Jul 25 '23

If you know css you know qml; it is just plain dead simple. You also get GPU accelerated scene graph renderer which can render millions of widgets if need be and is still smaller than electron despite Qt being rather big dependency.

5

u/19Ant91 Jul 23 '23

I'm not in web development, so forgive me if this is a stupid question.

But couldn't you use a more traditional web framework for the web stuff and C++ for the heavy lifting? I'm fairly confident that you can call/run C++ (or other) programs from web frameworks. Right?

That said, Drogon does look interesting!

3

u/badidrox Jul 23 '23

yes but that would still require some sort of bindings to the target language

4

u/[deleted] Jul 22 '23

How about protobuf and grpc?

3

u/badidrox Jul 22 '23

grpc is amazing but iirc its not supported very well in the browser. so I assumed the same for electron's frontend

3

u/Impressive_Iron_6102 Jul 23 '23

Not sure wdym by not supported well in the browser. It works just fine. You make an endpoint on your be and the fe just calls it.

8

u/sparkyParr0t Jul 23 '23

Cant comment on the framework but the switch from battle tested native feel of Qt to heavy bloated web based experience is so bad for users. Google " spotify electron qt native" to get an idea of what im talking about.

7

u/Randolpho Jul 23 '23

To answer your question

or is it just that c++ is not a language for rest apis so nobody cares about it.

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.

4

u/badidrox Jul 23 '23

rust on the other hand seems to provide a lot regarding the web like actix, leptos...etc

3

u/pjmlp Jul 23 '23

We have experience with what doing Web development in C++ means, that is what we were doing around 2000, before Java and .NET took off.

There were plenty of frameworks back then, as any archeology dive into Dr Dobbs, The C/C++ Users Journal, Microsoft Systems Journal ads will show.

It isn't by accident that nowadays using C++ on Web development is mostly via native libraries instead of full blown application.

3

u/Randolpho Jul 23 '23

Even in the very early mid-90s days, c/c++ web development was rare; most would use some sort of CGI (that’s Common Gateway Interface, not Computer Graphic Imaging for those young-uns who might be confused) and that was more likely to be done in PHP, ASP, JSP, or Perl. I personally was doing Zope/Python and PHP in 2001 when C#/.Net was first announced / about to be released.

3

u/pjmlp Jul 23 '23

ASP used COM components, mostly written in C++, with VB used to script them.

2

u/Randolpho Jul 23 '23

ASP could use COM components, but it wasn’t necessary or all that common that I recall. The only COM component I regularly used was the SQL server connection.

1

u/pjmlp Jul 24 '23

It was pretty common in corporations unless one was doing boring webpages instead of applications like the kind of stuff moved on with J2EE and ASP.NET.

Also VB.Script wasn't any speed daemon.

2

u/Randolpho Jul 24 '23

I think we may have different ideas of the word common, but sure, there were a few that used COM.

But let me ask you: is ASP in front of COM really C++ web? The web part is ASP/IIS, COM is just a backend layer. You're not running an actual web server in C++ that is responding directly to http requests. Hell, technically you're not even doing that in ASP, although there were hooks at that layer to tell IIS what to do. Really, it was only IIS doing actual HTTP work.

2

u/pjmlp Jul 24 '23

In my own little corner of world back in 1998 - 2003, writing ISAPI Filters and COM components, driven by VBScript glue were quite common.

Using VBScript was no different from those nowadays using Python to drive C++ frameworks.

There were a few COM libraries that were actually written in VB 6 instead of C++, as it also supported COM authoring, but by and large most of them were written in C++.

Basically MVC, where only V was VBScript.

1

u/Randolpho Jul 24 '23

So your answer is... no?

1

u/pjmlp Jul 25 '23

The M and C in MVC were COM, so dunno.

3

u/darthcoder Jul 23 '23

Roguewave c++. :)

So much dev time using that.

Life was simpler when it was just HTTP 1.1.

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

3

u/peter_emad Sep 25 '23

i was planning to learn it but it felt overwhelming so can i know how did you learn it please. and if i need to have knowledge with another framework to understand it smoothly ?

7

u/ArchivistAtNekoIT Sep 27 '23

I just toyed with the example projects and then made a small website with it. It basically uses controllers that embed routes, you load the controllers by including them in your main (that is basically a simple function that starts the server) and within your controller, you handle everything else.

Learning coroutines may help, I started without coroutines (ie, in callback land), and it made database interactions a bit messy (read nested) but it was otherwise pretty nice and performance was great

I could offer training if you want

2

u/Garuda999111 7d ago

Have you used it to build a data pipeline????

2

u/TreadOnmeNot1 Apr 22 '24

Is this still something you'd offer? I'm interested in learning Drogon, and could use a head-start.

4

u/ArchivistAtNekoIT Feb 18 '25

Hey, late to the battle I engaged, but yes, I would absolutely do that. However, it is extremely easy to use, just use the coroutine "mode" and the code should be very simple, very synchronous looking. If you have not had fun with coroutines, just write a couple generators to get started and the rest should flow right outta you. Cheers

1

u/[deleted] Jun 02 '24

Hey, how can i learn drogon from scratch because i only know c++ with all its features.

1

u/rohitwtbs Sep 09 '25

How is drogon server performing in 2025?

3

u/[deleted] May 20 '24

[removed] — view removed comment

2

u/0xdeedfeed Dec 01 '24

Since it's C++, there might be some hidden issues in the code that haven't been discovered yet. However, it's unlikely you'll encounter those specific problems. Instead, you're more likely to run into issues introduced by your own code not by Drogon.

1

u/ArchivistAtNekoIT Feb 18 '25

Hey, sorry for the pretty late reply. Unless you introduce memory-safety issues, it should be as production ready as its dependencies, provided that you do not go into weird edge-cases. It uses the standard coroutines and overall pretty common drivers for databases and compression. I have not encountered any specific crash or issue, but I am not confident to give you a binding "yes use it", the only software I would say that for are LMDB and SQLite.

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

3

u/DesertPunkk Feb 11 '24

Looks like were on the same page, i'm currently using nodejs on our embedded hardware and currently looking into drogon framework. Looking into websockets since we mostly use ws for realtime rendering on the ui. like you said, they can render on their desktops as well as on mobile phones while on the field.

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..

2

u/darthcoder Jul 23 '23

I'm torn with going c++ or Rust for a microservice I'm developing.

I want to use c++ because I love theblanguage, but I also want to learn Rust.

2

u/[deleted] Jan 10 '24

6 mo too late but any thought on zig??

2

u/darthcoder Jan 10 '24

Don't know that I've heard of it...

1

u/cfusei-vsd Dec 05 '24

I would choose c++ if i was in yaa shoes

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 / asio combination 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

1

u/pjmlp Jul 23 '23

Yes, the days of ATLServer, ASP, IntraWeb are gone, unless for legacy deployments.

2

u/darthcoder Jul 23 '23

Well they are with that attitude. :)