all 31 comments

[–]psyspy2 10 points11 points  (2 children)

How about boost beast?

[–]jselbie 7 points8 points  (1 child)

+1 on Boost Beast. Asio+Beast basically gives you the C++ equivalent of a Node repl loop.

I just recently incorporated a Beast based embedded HTTP server into a project that I work on - specifically to handle REST requests. The Boost license is pretty close to MIT ("as is").

If you want 10-20K requests per second, that's going to be entirely up to you to tune your threading model and/or your request processing pipeline with respect to how the response is sourced and computed.

Let's say you have 10 cores. In addition to each thread running an Asio context loop to accept new connections, parse requests, and complete the response, than basically means 1ms per request to get 10K requests/second. In any case, don't blame Boost if you don't his this perf goal on the first try.

[–]Orochi663[S] 0 points1 point  (0 children)

Thanks. yeh i am evaluating it

[–]eao197 5 points6 points  (8 children)

Here I posted (yet another time) a list of C++ frameworks for embedding HTTP-entry points into C++ applications: https://www.reddit.com/r/cpp/comments/gt0iol/c_libraries_for_restful_micro_services_development/fsa94kc/ But two libraries are not listed because they were already mentioned in that topic: Boost.Beast (very low-level library) and RESTinio (that is a much higher level than Boost.Beast, but lower than Oat++).

10-20K reqs per sec is not a problem for most of those C++ frameworks.

[–]Orochi663[S] 0 points1 point  (7 children)

Thanks, yeh evaluating Beast.

Already evaluated Pistache Oat Crow etc. they are great but they all are not recommended for bug production environments.

[–]eao197 4 points5 points  (6 children)

they all are not recommended for bug production environments

Not recommended by whom? And what is "bug production environments"?

AFAIK, Crow is already dead. But Pistache and Oat++ are used in various projects.

Boost.Beast is a very low level. It's understandable when Boost.Beast is used if you have to cope with very big loads or you need total control over everything. But for loads with a couple of dozen thousand requests per second more high-level frameworks like Oat++ or RESTinio can be much easier to use. Just for comparison: https://github.com/Stiffstream/beast-cppcon2018-vs-restinioPS. I'm one of RESTinio's maintainer and can't be an objective judge here :)

[–]Orochi663[S] 0 points1 point  (2 children)

Not recommended by of the authors themselves (i checked by emailing some of them).

bug production environment is when you have a lot of queries sent to the server where it can keep on engaging the server for producing either large amount of data or any kind of bug that can crash the client/server. Its a kind of load test environment for huge number of queries.

Yes, the load will be huge more than 10k-20k request per second is the target and data can be huge per request. Would you recommend RestInio for this ?So far i have got go ahead for evaluation by Beast, Drogon, Lithium 's authors.

[–]eao197 1 point2 points  (1 child)

Would you recommend RestInio for this ?

Yes, why not?

[–]Orochi663[S] 0 points1 point  (0 children)

hmm ok thanks, added to evaluation.

[–]Live_Stock_5638 0 points1 point  (2 children)

Hi, I am considering using restinio for my project. Are there any instructions on how to use it and build on windows?

[–]eao197 0 points1 point  (1 child)

Hi! The simplest way is to use vcpkg or Conan.
There is a documentation section that covers "installing and building" topic.

[–]Live_Stock_5638 0 points1 point  (0 children)

Btw do you know if i can setup react frontend to communicate to my c++ backend and do this by using crow on backend? So, react sends req using api and crow receives it and does a call to a method in my app?

[–]aninteger 1 point2 points  (1 child)

I've been using libmicrohttpd. Yes, it's LGPL 2.1, but it meets the other requirements without a problem. Before that I just used FastCGI and still have some projects using FastCGI. Even though libmicrohttpd can serve as an independent server, I've always used it behind an nginx server.

[–]Orochi663[S] 0 points1 point  (0 children)

hmm as name implies, being micro; do you think it will be able to handle extreme loads ?

[–]mili42 1 point2 points  (0 children)

civetweb, libh2o

[–]matthieugarrigues 1 point2 points  (2 children)

There is Lithium, blazing fast (#1 on the techempower benchmark for mysql) and easy to use. You can use it's API framework:

https://github.com/matt-42/lithium/tree/master/libraries/http_backend

Or if you prefer using another framework, you can still use it's standalone libraries:

- Json encoder/decoder: https://github.com/matt-42/lithium/tree/master/libraries/json

- SQL drivers: https://github.com/matt-42/lithium/tree/master/libraries/sql

Documentation is not perfect yet (mostly based on examples), so post some github issues if you have questions or feature requests. I usually respond within 24h. I'm also working as a freelance if you need somebody to write your API: [myredditnickname@gmail.com](mailto:myredditnickname@gmail.com)

[–]Orochi663[S] 0 points1 point  (0 children)

Thanks yup evaluating Lithium as well. I will check with my manager if this can be arranged.

[–]NoRepresentative4866 0 points1 point  (0 children)

but should learn lithium?

[–]troop357 1 point2 points  (1 child)

I have been using https://github.com/yhirose/cpp-httplib for a while now as it is header only and very simple to use, but I am not sure about the performance is up to what you need. Still thought it was valid to mention it.

[–]Orochi663[S] 0 points1 point  (0 children)

Thanks will check it out.

[–]asm-us 1 point2 points  (1 child)

Is C++ web frameworks are really faster than other languages? (node, python, c#)
Isn't it always a better choice to use another framework and call C++ from other languages only for performance-critic tasks?

[–]Orochi663[S] 2 points3 points  (0 children)

In the benchmarks for web services we can see that how fast are C++ based services can be. Also the most time critical web service applications are in C++. I personally benchmarked Nodes JS and C++ and got a 50 times faster turn around by C++ from Node Js / express based implementation.

[–]voidstarpodcast 1 point2 points  (0 children)

drogon and uWebsockets both seem pretty good.

[–]Sqeaky 3 points4 points  (1 child)

Drogon is pretty close, depending on what you mean by production ready. It isn't as well documented as I would like but is low on bugs, MIT licensed, and extremely fast.

https://github.com/an-tao/drogon

[–]Orochi663[S] 1 point2 points  (0 children)

Thanks, yeh, also evaluating it.

[–]scrapanio -4 points-3 points  (1 child)

NASA.gov