Http2 Tomcat

Posted on  by 



  1. Tomcat 9 Http2
  2. Tomcat Http2 Performance

HTTP/2 is now the official RFC 7540, and it’s about time to deploy your website on HTTP/2, to get the numerous benefits that HTTP/2 brings.

A very typical deployment is to have Apache (or Nginx) working as a reverse proxy to a Servlet Container such as Jetty or Tomcat.
This configuration cannot be used for HTTP/2, because Apache does not support yet HTTP/2 (nor does Nginx).

We want to propose an alternative deployment replacing Apache (or Nginx) with HAProxy, so that we can leverage Jetty’s 9.3.0 HTTP/2 support, and retain most if not all the features that Apache (or Nginx) were providing as reverse proxy.

Tomcat 9 Http2

For those that don’t know HAProxy, it’s a very fast load balancer and proxy that powers quite a number of the world’s most visited sites, see here.

For additional information on using HTTP/2, see: Apache Tomcat 9 Configuration Reference: The HTTP Connector - HTTP/2 Support. For information on the HTTP/2 Upgrade Protocol and the supported attributes, see: Apache Tomcat 9 Configuration Reference: The HTTP2 Upgrade Protocol. Tomcat's Mark Thomas has outlined support for HTTP/2 for Tomcat 9. Technology: HTTP2 is the major release of the HTTP network protocol used by WWW (world wide web). It is the recent new version of HTTP Protocol as HTTP 1.1 was released in 1997. It was derived from SPDY protocol, originally developed by Google. All the major browsers like Chrome, Opera, Firefox, Safari, Edge browsers are supporting this protocol. Tomcat 9 configuration, with HTTP/2 GitHub Instantly share code, notes, and snippets. There is a modproxyhttp21 module but it is still experimental. Like detailed in the StackOverflow answer provided in the second edit, you could use modhttp2 to enable HTTP/2.0 support on Apache side, and communicate back to the Tomcat server either with HTTP/1.1 or AJP. But you would loose one of HTTP/2.0 biggest feature: multiplexing.

Tomcat http2 without ssl

What you will get is a very efficient TLS offloading (performed by HAProxy via OpenSSL), and Jetty HTTP/2 support, including HTTP/2 Push.

Http2

The setup to make HAProxy + Jetty + HTTP/2 work is fairly simple, and documented in detail here.

Don’t wait years to update your website to HTTP/2: whether you run a JEE web application, or a PHP application like WordPress, HAProxy and Jetty can speed up your website considerably, and many studies have shown that this results in more business.
Browsers like Firefox and Chrome already support HTTP/2, so you will get more than half of the world potentially accessing your website with HTTP/2.

Contact us if you want to know more about HTTP/2 and how we can help you to speed up your website.

Description

dotCMS 5.0 ships with Tomcat 8.5 which supports the HTTP2 protocol. HTTP2 is a modern version of HTTP that can combine multiple requests into a single request (among other benefits), greatly increasing client performance when accessing sites. If you are interested in trying to run dotCMS with HTTP2 enabled there are a few things you will need. First off, HTTP2 requires SSL and will not work without it, so you will need a valid certificate file and key. Second, if you are running tomcat without a proxy server or load balancer in front, you will need the APR library installed, which allows tomcat access to system native (non-java) libraries for better performance. You will need to apt-get apr or yum -i apr or brew install apr in order to get this running correctly. Once you do this, hit your site with https and check out your browsers developers tools to insure that you are seeing the connections using HTTP2. Your network connections should look something like the attached image.

And below that is the snippet of code that activates HTTP2 in your server.xml

Tomcat Http2 Performance

To learn more about the benefits of the HTTP2 protocol, see: https://en.wikipedia.org/wiki/HTTP/2





Coments are closed