crow icon indicating copy to clipboard operation
crow copied to clipboard

Crow being "very fast"

Open QuantScientist3 opened this issue 8 years ago • 8 comments

Hi, I have been using Crow for a real time project in which requests are made using HTTP post (REST + JSON) and a response is created on the fly (again JSON).

The size of the json object is about 1000 bytes. With a single connected user (using Apache AB/Jemeter etc) I get consistent results with an average of only ~2500 requests per second on a strong 10 CPU machine on EC2.

No business logic is involved, only parsing JSON and creating a JSON object back. Has anyone had better results? I am using the jsonxx lib since the default json lib was even slower.

I really need around 20,000 RPS at the bare minimum. Using netty/vertx.io with the same JSON I get around 25,000 RPS.

Any insights would be appreciated.

QuantScientist3 avatar Mar 14 '16 14:03 QuantScientist3

You really need to show us (or, maybe, stackoverflow) some code / build options / etc. it could be aggressive string caching with netty, or something like this. http://kellabyte.com/2013/08/20/http-response-caching-in-haywire/ here's a related interesting article, btw.

digitalist avatar Mar 14 '16 22:03 digitalist

If you need a serious real-time performance, how about writing a server over binary protocols using FlatBuffer or CapNProto ? HTTP and JSON encoding/decoding affect the performance.

It seems like that asio and crow copying send buffers more times than netty.

ipkn avatar Mar 15 '16 03:03 ipkn

btw @GP-GPU did you try rapidjson? (benchmarks: https://github.com/miloyip/nativejson-benchmark)

digitalist avatar Mar 15 '16 06:03 digitalist

Thank you for the replies. I am going to investigate further and come back. Best,

QuantScientist3 avatar Mar 15 '16 09:03 QuantScientist3

@GP-GPU how's investigation going?

digitalist avatar Mar 30 '16 00:03 digitalist

I moved to using RapidJson when handling req.body which is much faster than the default json lib. Also, when producing json, i use fmt::fromat lib which is also much faster.

QuantScientist3 avatar Mar 30 '16 21:03 QuantScientist3

thanks, I was wondering about fmt::format too. Guess this issue can be closed now, though maybe you should make a pull request with edited README .md with a note about rapidjson.

digitalist avatar Mar 30 '16 21:03 digitalist

@QuantScientist3 or anyone else

Could you show a simple example of how you used RapidJson in the crow endpoint? Thanks a lot!

alejandroarmas avatar Jun 10 '21 01:06 alejandroarmas