lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

is there anything faster than lwan? #308

Closed hiqsociety closed 3 years ago

hiqsociety commented 3 years ago

is there anything faster than lwan?

i'm looking for the fastest c implementation with maximum number of concurrent keepalive or non keep alive connection

lpereira commented 3 years ago

That's a very difficult question to answer, because there are a lot of dimensions to benchmark against. Although I can't claim that there isn't anything faster than Lwan, I'd say that it's pretty much up there as far as efficiency (if you consider low latency, high throughput, and conservative memory usage) goes with the leading pack of servers.

hiqsociety commented 3 years ago

thx for the great work.

  1. trying to understand what's the memory requirement per connection for lwan etc. do u know roughly how much mem is required per connection?

  2. i was looking through online and found this. how much mem per coroutine for it too? https://gist.github.com/lpereira/2154951

  3. possible to benchmark (or provide feedback) against this? https://www.embedthis.com/ or https://github.com/denoland/deno/issues/1205 (i wonder if libuv or libev or libhv is faster etc)

lpereira commented 3 years ago
  1. The major memory requirement is the stack size for each coroutine. At the moment, this is about 4 * SIGSTKSZ, which is about 8KB on x86-64 Linux (although this can be different). A bit more memory per connection is necessary (at least 32 bytes per connection). So, for 10k connections, you'd need something in the ballpark of 320MB of RAM at least.
  2. The coroutine implementation you posted was written by myself. It's a very old implementation that Lwan used to use, and the current version being used by the server is better.
  3. Feel free to benchmark and post the results.
hiqsociety commented 3 years ago

amazing work!

32kb per connection is quite high. is coroutine the issue? maybe can use this one? https://github.com/hnes/libaco

lpereira commented 3 years ago

It's not trivial to reduce this number. I've made a lot of experiments. If it's a stackful coroutine, it's kinda difficult to carry around a stack smaller than this number.

On Fri, Sep 10, 2021, 17:53 hiqsociety @.***> wrote:

amazing work!

32kb per connection is quite high. is coroutine the issue? maybe can use this one? https://github.com/hnes/libaco

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lpereira/lwan/issues/308#issuecomment-917307795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADVGLXYOEDFKM6TMELI3DUBKSB5ANCNFSM5DYL34EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

hiqsociety commented 3 years ago

ok thx. keep up the great work!