Thursday, April 16, 2015

HTTP/2 is much faster than SPDY thanks to dependency-based prioritization


HTTP/2 provides two methods to prioritize streams (e.g. files being served).

One method is called weight-based prioritization. In weight-based prioritization, every stream is given a weight, and the value is used by the server to proportionally distribute the bandwidth between the streams.

The other method is dependency-based prioritization. By using the method, web browsers can advise HTTP/2 servers to send the streams that are depended by other streams before sending the other streams. For example, by using dependency-based prioritization web browsers can request the server to send CSS or JavaScript files before sending HTML or image files.

As of this writing, out of the two popular web browsers that implement HTTP/2, only Firefox uses dependency-based prioritization.

Note: the background section has been rewritten due to the fact that the comparison with SPDY turns out to be wrong, as pointed out in the comment. The original version of the section is here. Rest of the blogpost stays in tact.

The case of Mozilla Firefox

The prioritization strategy of Firefox is as follows1:
  • send CSS and JavaScript files in <HEAD> before HTML and/or image files by using dependency-based prioritization
  • HTML streams are given 2.5x bandwidth above image streams (by using weight-based prioritization)
  • script files within <BODY> are in total given about the half bandwidths of the other files2

Below is the network time chart generated by Firefox 37.0.1 when accessing a sample web page3 (given 100ms network latency6) containing a number of CSS, script files, and images. H2O version 1.2.0 was used as the HTTP/2 server for running the benchmark.

By looking at the chart, you can see that many CSS, script files and images are requested in parallel at some time around 320ms, but that the download of files that block rendering (e.g. CSS and script files) complete before any of the images (even the smallest ones) become available. This is due to the fact, as I explained earlier, that Firefox notifies the HTTP/2 server that HTML and image files depend on the CSS and the script files to become rendered; therefore the server is sending the files being depended before sending the dependents. And thanks to the prioritization, all the files that are required to do the initial rendering arrives at the web browser (a.k.a. first-paint time) at around 1.0 seconds from start.

The case of Google Chrome

On the other hand Chrome's prioritization logic only uses the weight-based prioritization; the logic remains mostly same with that used in SPDY. Chrome assigns a predefined weight to each of the stream based on their types.

Table 1. Priority weight values used by Google Chrome4


And here is the timing chart taken using Chrome (version 44.0.2371.0 canary) when accessing the same web page.

Unlike Firefox, CSS and script files are not arriving before the image files. If you look carefully, you will find a vague relationship between the size and the arrive time of the contents independent to their types. This is because each of the files are interleaved into a single TCP stream based on their weights, and because of the fact that the weight between the files do not differ much. Therefore the initial-paint time is as late as 1.5 seconds5.


As shown, dependency-based prioritization introduced in HTTP/2 brings non-negligible benefit in terms of web-site performance. In case of the benchmark, Firefox using dependency-based prioritization was 1.5x faster than Google Chrome only using weight-based prioritization when comparing the first-print timings.

My understanding is that the developers of Chrome is aware of this issue, so hopefully it will be fixed soon. I also hope that other web browser vendors will utilize dependency-based prioritization. As shown, it is clearly the way to go!

PS. And it should also be worth noting that HTTP/2 servers should implement the prioritization logics correctly. In case of H2O, the server both of the prioritization logics are fully implemented using a per-frame weight-based round robin with the frame size of 16Kbytes at maximum.

note 1: ref: HTTP/2 Dependency Prioritization in Firefox 37, Http2Stream.cpp line 1088 of Firefox
note 2: ref: nsScriptLodare.cpp line 306; I am not sure if this is the intended behavior, IMO script tags in BODY should given a priority equiv. to HTML or image files, and it might be the case that the condition of the if statement should be reversed.
note 3: was used for testing the load speed, with the <script> tags at the end of the document moved into <HEAD>
note 4: ref: MapPriorityToWeight function of Chrome
note 5: the network chart of Chrome includes a 0.2 second block before initianting the TCP connection, which has been subtracted from the numbers written in this blog text.
note 6: An Ubuntu 14.04 instance running on VMware Fusion 7.1.1 on top of OS X 10.9.5 was used for running the server. Network latency was given using tc qdisc command. Both the web browsers were run directly on OS X 10.9.5.


  1. Slight correction. SPDY priorities were similar to dependencies in that higher priority streams were to be delivered before lower priority streams ( ). It was only in HTTP/2 that the priorities became weights.

    1. Thank you for the correction. I had thought that the priorities in SPDY is weight-based since in Chrome they are mapped to weights of HTTP/2.

      If that is the case, is my understanding correct that Chrome actually becomes slower by switching from SPDY to HTTP/2 in terms of first-paint time, in case of viewing a web-site like the one explained on this blogpost?

    2. Correct, at least until Chrome moves from using weights to HTTP/2 dependency groups.

    3. Thank you for the response.

      I hope Chrome would get updated so that it would work better with HTTP/2. Meanwhile I might add some tweaks to H2O so that it can provide better experience to the users of Chrome.

      I will also update the blogpost to reflect your collections (I've already updated the background section). Thank you very much for your help!

  2. This comment has been removed by the author.

  3. I like this a lot. Thank you for sharing. I'm always looking for upcycles like this. In the end, you don't know it was a shipping pallet to begin with!
    Kolkata Knight Riders Team Squad Captain Name
    RCB New Players List
    Kings XI Punjab New Jersey Logo Images

  4. There are so many areas of software development and online services available today that many people feel that they have to hire professional web design services, it is essential.
    Take a look: html and css

  5. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.
    dark souls 3 emoji
    slitherio supersnakeio

  6. I am very grateful for this enlightening article. I am new to this issue, but for me it elucidated several questions. Congratulations on your knowledge on the subject. Thank you very much.aPortrait Professional Studio 10.9.5

  7. Objek wisata gunung bromo menjadi primadonya jawa timur karena wisata ini memang sangat fenomenal di kalangan para wisatawan. Banyak para pengunjung yang datang dari luar negeri untuk menikmati keindahan alam di wisata gunung bromo. Hamparan pasir yang luas dan dinginnya hawa pagi di wisata gunung bromo menambah keseruan saat berlibur ke wisata gunung bromo jawa timur tersebut.
    Pelayanan jasa sewa mobil malang murah sangat diburu oleh para wisatawan yang sedang berlibur di kota malang batu. Jasa sewa mobil murah malang ini bisa menjadi ladang bisnis yang menggiurkan, karena mengingat banyak para wisatawan yang datang dari luar membutuhkan transportasi sewa mobil malang murah. Beragam pilihan paket sewa mobil malang murah dan juga bermacam-macam tipe mobil yang disediakan oleh sewa mobil malang batu murah. Informasi pemesanan dan booking online sewa mobil malang murah baca halaman lengkap.
    Racikan ampuh jamu kuat dan tahan lama yang dapat dengan mudah mengatasi masalah ejakulasi dini adalah dengan memakai ramuan herbal madura. Obat kuat yang berasal dari madura sangat populer di kalangan pria yang menginginkan hubungan seksual tahan lama agar bisa menikmati kenikmatan saat berhubungan intim tersebut. Jamu tahan lama seksual ini diolah menggunakan bahan-bahan tradisional dan sudah terdaftar resmi di badan kesehatan republik indonesia. Jadi anda tidak perlu khawatir saat mengkonsumsi jamu kuat alami dari madura ini, tidak ada dampak negatif sedikitpun bagi kesehatan tubuh. artikel terkait . Harga jual jamu kuat dan tahan lama produksi ramuan madura asli obat kuat tahan lama.

  8. HTTP/2 is much faster than SPDY thanks to dependency-based prioritization sprei anti air

  9. Thank you for sharing this data. Really increase in value the way you have describe everything in this article. Keep up the decent work. hotmail login | gmail sign up | hotmail email login | hotmail account login

  10. Harga rak sepatu gantung yang dijual secara online yaitu Rp.75.000 per pcs. Namun berbeda dengan produsen yang menjual produk organizer rak sepatu gantu g dengan harga 65.000 rupiah saja. Lebih murah bukan? Dan jika anda membeli dengan pembelian minimal 3 pcs (reseller) maka akan mendapatkan diskon khusus. Apalagi pembelian rak sepatu gantung dengan jumlah minimal 1 lusin dan minimal 100 pcs. Anda akan mendapatkan super diskon. Sampai saat ini masih dicari reseller, agen dan distributor yang siap bekerja sama memasarkan produk organizer ini. Silahkan anda bandingkan sendiri harga rak sepatu gantung resleting di tempat kami dengan produsen lainnya. Kualitas bahan yang digunakan untuk membuat rak sepatu gantung karakter ini merupakan yang terbaik. Pesan rak sepatu gantung kepada kami sekarang juga.

  11. This comment has been removed by the author.

  12. This comment has been removed by the author.

  13. Love to visit your blog again. Home designer pro a software that can work.

  14. دار السلام اهم شركة نقل عفش بالطائف وكذلك اهم شركة نقل عفش بمكة وجدة والمدينة المنورة تقوم الشركة بنقل العفش بحفر الباطن وتبوك وجازان وتقوم بنقل الاثاث بالقصيم
    شركة نقل عفش بالطائف
    شركة نقل عفش بالمدينة المنورة
    شركة نقل عفش بجازان وابها

  15. Leading Dubai Visa service provider company in India Dubai Tourist Visa