Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is h2o so fast? #1497

Closed
voiddeveloper opened this issue Nov 10, 2017 · 6 comments
Closed

Why is h2o so fast? #1497

voiddeveloper opened this issue Nov 10, 2017 · 6 comments

Comments

@voiddeveloper
Copy link

voiddeveloper commented Nov 10, 2017

I am learning why h2o is fast.

  1. What does "Unlike most parsers, it is stateless and does not allocate memory by itself. All it does is accept pointer to buffer and the output structure, and setups the pointers in the latter to point at the necessary portions of the buffer." mean?

When I read ppt or read git's "read me" it says "fast" because it is "Unlike most parsers, it is stateless and does not allocate memory by itself. All it does is accept pointer to buffer and the output structure, and setups the pointers in the latter to point at the necessary portions of the buffer."
I do not understand what it means. I would be grateful if you explain in detail.

I would really appreciate it if you let me know.

@sudarsha
Copy link

sudarsha commented Nov 10, 2017

my seige benchmark results on an Uplcoud 2GB instance using Lan connections

Command -- siege -v -d1 -c250 -i -f siege.txt

siege.txt has 65 urls (all cached, and served by the server itself)

h2o

Transactions: 12766 hits
Availability: 99.86 %
Elapsed time: 35.62 secs
Data transferred: 580.61 MB
Response time: 0.67 secs
Transaction rate: 358.39 trans/sec
Throughput: 16.30 MB/sec
Concurrency: 240.01
Successful transactions: 12766
Failed transactions: 18
Longest transaction: 4.64
Shortest transaction: 0.00

nginx

Transactions: 9909 hits
Availability: 99.77 %
Elapsed time: 34.35 secs
Data transferred: 455.19 MB
Response time: 0.84 secs
Transaction rate: 288.47 trans/sec
Throughput: 13.25 MB/sec
Concurrency: 242.80
Successful transactions: 9905
Failed transactions: 23
Longest transaction: 8.84
Shortest transaction: 0.00

Caddy

Transactions: 12145 hits
Availability: 99.44 %
Elapsed time: 35.07 secs
Data transferred: 635.66 MB
Response time: 0.69 secs
Transaction rate: 346.31 trans/sec
Throughput: 18.13 MB/sec
Concurrency: 239.72
Successful transactions: 11813
Failed transactions: 69
Longest transaction: 1.97
Shortest transaction: 0.00

@deweerdt
Copy link
Member

When I read ppt or read git's "read me" it says "fast" because it is "Unlike most parsers, it is stateless and does not allocate memory by itself. All it does is accept pointer to buffer and the output structure, and setups the pointers in the latter to point at the necessary portions of the buffer."
I do not understand what it means. I would be grateful if you explain in detail.

That means that when H2O receives a request, the HTTP parser itself, doesn't allocate any memory besides to the one necessary to receive the request. The HTTP/1 parser that H2O uses is picohttpparser, it has its own repository: https://github.com/h2o/picohttpparser . The source is small enough, and it has small tests https://github.com/h2o/picohttpparser/blob/master/test.c that demonstrate its use.

@xm74
Copy link

xm74 commented Nov 11, 2017

@sudarsha These are the results for HTTP/2 ?

@ghost
Copy link

ghost commented Nov 11, 2017

@xm74 seems not, because siege doesn't support HTTP/2 yet.

@sudarsha
Copy link

Siege doesn't support it. h2load has, but I haven't got around to configuring it.

@voiddeveloper
Copy link
Author

voiddeveloper commented Nov 13, 2017

@deweerdt
Thanks to this, I became a chance to understand a little more.
Thank you very much.
I have a question.
I know that "picoparser" is the role of parsing http messages.
Is there a store?
In ppt, it is referred to as a buffer. What buffer is the buffer?
Is it a buffer on the web server? Is it a buffer in picoparser?

And "stateless" means speed?
Please explain in detail.

I do not have enough English. I'm sorry if it sounded awkward to my question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants