Eilon / MauiHybridWebView

MIT License
206 stars 44 forks source link

Bypass concurrent connection limits #75

Open rbrundritt opened 1 month ago

rbrundritt commented 1 month ago

Looking at the network trace I noticed that all requests to the local root (0.0.0.0) are using http/1.1 protocol. This means that parallel requests to this domain will be limited to 6-8 connections at a time depending on the platform. This causes blocking as addiitonal requests have to wait for one of the connections to free up. For small JSON requests/apps this isn't that big of an issue, however, I've been testing the limits (lots of requests, and requests with longer response times) and noticed that this does impact performance compared to running a similar application hosted on a server with http/2 enabled.

image

There are a couple options we can explore to gain some performance here:

  1. Figure out how to enable http/2 (http/3 isn't yet fully supported in Safari). Http/2 is meant to remove the limit on parallel requests.
  2. Leverage subdomains. Before http/2 the way to get around these browser limits was to use subdomains on request. This could allow you to match the total connection limit of the browser while using a single domain. Now since we are using an IP address, and they don't have subdomains, this might be difficult to achieve. Maybe adding port numbers would do the same thing?

For places where we are using HttpClient, we could do something like the following to enable http/2

HttpClient myHttpClient = new HttpClient
    {
        DefaultRequestVersion = HttpVersion.Version20,
        DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrLower
    };