9
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved. Cache-aware Server Push in H2O version 1.5 Kazuho Oku DeNA Co., Ltd. 1 Cache-aware Server Push in H2O version 1.5

Cache aware-server-push in H2O version 1.5

Embed Size (px)

Citation preview

Page 1: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

1

Cache-aware Server Pushin H2O version 1.5

Kazuho OkuDeNA Co., Ltd.

Cache-aware Server Push in H2O version 1.5

Page 2: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

2

Finding out what is NOT cached

Cache-aware Server Push in H2O version 1.5

Page 3: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

3

Cache Fingerprinting include in every HTTP request a fingerprint of

the cached blocking assets (e.g. CSS and script files) belonging to the same origin⁃ server uses the fingerprint to determine what

should be pushed algorithm: Golomb compressed sets

⁃ compressed form of Bloom filter⁃ key(asset) = sha1(asset_URL + asset_etag)⁃ estimated size: 1.x * N * log2(1/P) bits

⁃ N: # of entries, P: possibility of false positive⁃ e.g. 800 bits for 100 asset files, 1% false positive

Cache-aware Server Push in H2O version 1.5

Page 4: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

4

Calculating the Fingerprint ServiceWorker

⁃ iterate though the SW cache and calculate⁃ the issue: SW may not be running• esp. for first visit or returning user (after some

time), in which case we need to push things Cookie

⁃ calculate in server, and set it as a Cookie⁃ can always be used⁃ the issue: can't update when a cache entry gets

purged• means there might be false positives

Cache-aware Server Push in H2O version 1.5

Page 5: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

5

Calculating the Fingerprint hybrid approach

⁃ use Cookie header to send the fingerprint⁃ store response in SW cache whenever possible• even if SW is not activated (yet)

⁃ in SW, always recalculate the fingerprint and update the Cookie• so that the values becomes precise

Cache-aware Server Push in H2O version 1.5

Page 6: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

6

Cookie-based impl. in H2O version 1.5 tracking issue: github.com/h2o/h2o/issues/421

⁃ thanks to Jxck, Ilya, Tatsuhiro for the feedbacks! H2O cancels push indications sent from backend, if

client is likely to already have the data in cache hybrid impl. in the works

Cache-aware Server Push in H2O version 1.5

Page 7: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

7

Configuration (H2O 1.5)mruby.handler: | lambda do |env| push_paths = [] if /(\/|\.html)$/.match(env["PATH_INFO"]) push_paths << "/search/jquery-1.9.1.min.js" push_paths << "/search/oktavia-jquery-ui.js" ... end return [ 399, # delegate the request to next handler push_paths.empty? ? {} : {"link" => push_paths.map{|p| "<#{p}>; rel=preload"}.join("\n")}, [] ] endfile.dir: /path/to/doc-root

Cache-aware Server Push in H2O version 1.5

Page 8: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

8

Demo Web server (H2O) tracks the cache fingerprint

⁃ and cancels the push if the client has the asset• or, we might push 304

⁃ or actually does the push if otherwise

Cache-aware Server Push in H2O version 1.5

Page 9: Cache aware-server-push in H2O version 1.5

Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.

9

Benchmark scores first-paint does not change

⁃ reason: no dependency chain bet. assets, packets arriving in batch for every RTT

unload is delayed (since assets arrive before HTML)

Cache-aware Server Push in H2O version 1.5