Drogon C++, The Fastest Web Framework in the World

It was first placed in tests with 105 frameworks, among them: Rails, Django, NestJS, Laravel and others.

Drogon C ++, The Fastest Web Framework in the World

Drogon is a Web Framework written with C++ that works on both C++14 and C++17 versions.

The TechEmpower website (ranking link) has some benchmark services that test the performance of some technologies and among these tests, it analyzed the performance of Web Frameworks for Back-end and Drogon was the first placed in tests with 105 frameworks, among them: Rails, Django, NestJS, Laravel and others.

  • The name Drogon comes from the dragon called Drogon from the Game of Thrones series.
  • It is available for Linux, macOS, FreeBSD, OpenBSD and Windows.
  • Uses an epoll-based non-blocking I/O network library (and in the case for macOS and FreeBSD uses kqueue).
  • It supports the HTTP 1.0 and 1.1 protocol (for both server-side and client-side);
  • It has support for cookies and embedded sessions.
  • It also has support for: HTTPS (with OpenSSL), WebSocket, request and response for JSON format, widely used for Restful API
  • In addition to AOP with joinpoints and among several other features.


To install, you will first need some dependencies at compile time and at run time. They are:

For systems that use APT: Debian, Ubuntu, Mint and derivatives, just run this command below:

sudo apt install git gcc g++ cmake libjsoncpp-dev uuid-dev openssl libssl-dev zlib1g-dev

For systems using Portage: Gentoo, Funtoo and derivatives:

sudo emerge dev-vcs/git jsoncpp ossp-uuid openssl

For systems that use RPM: Fedora, Red Hat and derivatives

sudo dnf install git gcc gcc-c++ cmake libuuid-devel openssl-devel zlib-devel 


If in the future you will develop applications that use databases (which I believe so), it is extremely important that you install them before installing Drogon. It can be one of those listed below:

Drogon Installation

git clone
cd drogon
git submodule update --init
mkdir build
cd build
cmake ..
make && sudo make install


For this basic example we are going to create a static page without querying the database

1. Example 1 (The basics of the basics)

1.1 - Creating the project

cd $HOME
drogon_ctl create project my-project

Now my my-project has the following files:

├── build
├── CMakeLists.txt
├── config.json
├── controllers
├── filters
├── models
│   └── model.json
├── plugins
└── views

6 directories, 4 files

1.2 - Changing the file port

The original file is on port 80, but this could be a conflict on your system. Then change, for example, to port 8080.

If you also have a problem with port 8080, use port 1024 or try a port bigger than it that is not being used, to find out if it is being used use nmap, for example, to find out. Do not use ports less than 1024 as they should only be used for privileged users (root, for example).

cd my-project

With the following content:

#include <drogon/HttpAppFramework.h>
int main() {
    return 0;

And compile:

cd build
cmake ..

Now run the binary file that was created inside the directory you are in (build). In my case, as I called the project my-project, there is a binary with that name, so just run it:


Access the address: . And accessing it you will already find a beautiful 404:

Drogon 404

To “take down” the server’s execution, press: Ctrl + C. But that means it’s already working. Then just add an HTML page (still inside the build directory) and access it again:

echo '<h1>Server with Drogon C++, running cool!</h1>' > index.html

And go to:

2. Creating a Controller

We are going to create a test controller named ListController just to display the phrase: “My controller list”. At the root of your project, enter the directory: controller and run the following command to create the controller.

cd controller/
drogon_ctl create controller ListController

The output should be: create a http simple controller: ListController.

Two files were created: and ListController.h

2.1 - Editing the files

First, let’s edit the file: ListController.h and add these two lines:


The final file looks like this:

#pragma once
#include <drogon/HttpSimpleController.h>
using namespace drogon;
class ListController:public drogon::HttpSimpleController<ListController>{
    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;

And the file should look like this:

#include "ListController.h"
void ListController::asyncHandleHttpRequest(const HttpRequestPtr& req, 
                                            std::function<void (const HttpResponsePtr &)> &&callback){
    auto resp=HttpResponse::newHttpResponse();
    resp->setBody("My controller list");

Recompile the project and access:

cd ../build
cmake ..

Now both at the root (http://localhost:8080/ via get or post) and at http://localhost:8080/list we will get content.

If you are using Postman you will notice that the root will return the information for both GET and POST, but the /list will only return for GET.

The address of the official Drogon on GitHub is:, there you can get information of all documentation to install and develop your web applications.

If you want to watch a video featuring all the resources provided in this article, watch the video below:

The video is in Brazilian Portuguese, but you can use subtitles and translate into your language.

cpp webdevelopment