H2o: Why is h2o so fast?

Created on 10 Nov 2017  路  6Comments  路  Source: h2o/h2o

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.

Most helpful comment

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

All 6 comments

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

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.

@sudarsha These are the results for HTTP/2 ?

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

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

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

utrenkner picture utrenkner  路  5Comments

utrenkner picture utrenkner  路  7Comments

utrenkner picture utrenkner  路  8Comments

Ys88 picture Ys88  路  5Comments

paulpref picture paulpref  路  5Comments