gnet icon indicating copy to clipboard operation
gnet copied to clipboard

is there any way to low down the latency?

Open cctse opened this issue 5 years ago • 5 comments

It's really unacceptable compare to actix-web

# actix-web hello world
❯ wrk -t2 -c400 -d30 http://127.0.0.1:8003
Running 30s test @ http://127.0.0.1:8003
  2 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.49ms    1.42ms  37.84ms   89.36%
    Req/Sec    39.17k     6.07k   53.37k    87.92%
  2341083 requests in 30.09s, 290.24MB read
  Socket errors: connect 0, read 2, write 0, timeout 0
Requests/sec:  77805.54
Transfer/sec:      9.65MB

~ took 30s

# gnet  http hello world
❯ wrk -t2 -c400 -d30 http://127.0.0.1:8005
Running 30s test @ http://127.0.0.1:8005
  2 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    31.15ms   44.52ms 455.23ms   82.66%
    Req/Sec    44.67k     5.97k   55.07k    79.17%
  2667833 requests in 30.03s, 274.78MB read
  Socket errors: connect 0, read 30, write 0, timeout 0
Requests/sec:  88836.18
Transfer/sec:      9.15MB

~ took 30s

cctse avatar Jun 02 '20 16:06 cctse

gent mentioned above was running in one core,the latency was not so bad when running in multicore, but the qps fall back

# gnet hello world with multi-core
❯ wrk -t2 -c400 -d30 http://127.0.0.1:8005
Running 30s test @ http://127.0.0.1:8005
  2 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.74ms    2.06ms  57.74ms   92.88%
    Req/Sec    39.30k     5.86k   63.58k    76.42%
  2345670 requests in 30.06s, 241.60MB read
  Socket errors: connect 0, read 172, write 0, timeout 0
Requests/sec:  78038.99
Transfer/sec:      8.04MB

~ took 32s

cctse avatar Jun 04 '20 06:06 cctse

gnet can do more req/s than actix-web, that's amazing. would like to see a full fledge web server example to go along with it, not just a simple hello world though. BUT... where's this hello world code?

gitmko0 avatar Aug 29 '20 09:08 gitmko0

@gitmko0 since this is a low level framework, you need implement the http protocols youself. check sample code, add your "Hello World!" to Encode or Decode。also run with low memory, about 7m

cctse avatar Aug 29 '20 10:08 cctse

this is a bit too low level. is there anyone willing to make it a codeable / usable thing like fasthttp? is any of this sort in progress? also, what's the advantage in this? this gnet reminds me of smf... https://github.com/smfrpc/smf maybe can get some ideas from there to make it faster.

anyway, back to the topic. i'm here on gnet coz i saw http performance and i'm looking for something like fasthttp. so... can we get fasthttp kind of way for us to program on if anyone is expanding this to fasthttp, the velocity of adoption will be there.

gitmko0 avatar Aug 29 '20 11:08 gitmko0

As @cctse said, gnet is a low-level networking framework which provides the most basic functionalities for other frameworks/libraries in application layer, I encourage developers to build application-layer frameworks/libraries on top of gnet, but that's up to them.

Besides, please open a new issue for your new topic about gnet instead of adding comments in an irrelevant issue.

panjf2000 avatar Aug 29 '20 11:08 panjf2000