-1

We finished developing our prototype using Node.JS and Express.JS (which works with HTTP1.1) and I am trying to upgrade to HTTP2. However I am having a lot of troubles to do this.

I first discovered that Express.JS does not support HTTP2, and the release of Express.JS 5 which should resolve this issue is postponed every year.

I tried others solutions like Fastify or Koa, but there are a lot of issues or bugs with them. Documentation will say something but then typescript will complain and at the end I spend 5h just trying to install basic stuff like a view engine.

At the end I started wondering if it won't be best for us to write our own routers supporting HTTP2.

Is it that hard? Or does it require that much of effort?

Our needs are quite simple:

  • Some API routes to handle some business logics and communicate with the services
  • Some views that do server side rendering and serve the result
4
  • 2
    What features of HTTP/2 are you trying to use? E.g. are you interested in server push, or just general performance improvements? The latter could be potentially achievable using a reverse proxy, similar to what Cloudflare does. Commented Jul 4, 2021 at 8:25
  • Yes for now it is just about the performance improvement, but the idea is that I would really appreciate having access to HTTP2 features in the code. Commented Jul 4, 2021 at 8:29
  • 1
    "leverage" is a meaningless word here Commented Jul 5, 2021 at 11:14
  • Sorry English is not my first language, I changed the word for a more meaningful one. Commented Jul 5, 2021 at 12:43

1 Answer 1

3

HTTP/2 contains various performance improvements over HTTP/1.1. For example, this includes header compression and multiplexing of multiple responses over the same connection. These can be applied transparently by a proxy without the web framework having to be involved. Other improvements such as HTTP/2 server push do need explicit support by the backend, and is somewhat rarer.

In practice, this often leads to an architecture where your backend speaks HTTP/1.1, but you use a proxy such as Nginx that offers HTTP/2 to the clients:

+--------+  HTTP/1.1  +-------+
|        | <--------> |       |  HTTP/1.1  +---------+
| Client |            | Proxy | <--------> | Backend |
|        | <--------> |       |            +---------+
+--------+   HTTP/2   +-------+

This architecture is pretty much ideal. Using a reverse proxy in front of the backend is already a standard security practice, and often used for TLS termination and for serving static files. HTTP/2 can improve performance on high-latency connections (such as the Client's connection), but has no tangible benefits on low-latency connections such as those within a data centre. Thus, using HTTP/1.1 for communication between the reverse proxy and the backend is perfectly fine.

Indeed, using HTTP/2 for upstream connections could reduce performance since HTTP/2 is still built upon TCP, and inherits its head-of-line blocking problems. This changes with HTTP/3, but it has yet to be widely supported, and probably won't provide substantial value for connections within a data centre.

1
  • Thank you very much @amon, I updated the configuration of our reverse proxy on the server and it did the trick. We'll just continue with Express.JS for now. It's sad that we won't have access to HTTP2 features, but to be fair we don't have any planned feature to implement around HTTP2 so .. Commented Jul 4, 2021 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.