webcontainer-core
webcontainer-core copied to clipboard
The initial webcontainer booting takes 10 sec to complete
First of all, thanks for the great project.
I have created a react pkg using the @webcontainer/api called react-node-repl
And I deployed the same in a website with playground here: https://node-repl.pages.dev/
The problem is that it takes about 10 seconds to boot initially, but subsequent request or full page reload does booting in less than 5 seconds.
And the behavior is same for other browsers also.
My question is Can we reduce the initial booting time?
Also, my understanding how it works is, the api creates an iframe within the page and load wasm from the blitz headless endpoint and boots it with some service worker. Is it correct?
hi! :wave: thanks for reporting this issue!
We're always trying to improve boot times in WebContainer. However, when I test the provided link, WebContainer seems to boot in 2 seconds, then moves onto installing dependencies.
Are you including the dependency install in your figures? if so you might be able to save some time by preloading these dependencies rather than installing them each time.
If not, perhaps this delay is network connection related?
@kirjavascript thanks for testing out.
No, I'm not including the installation time here, just only booting.
If not, perhaps this delay is network connection related?
This brings another question, is the blitz endpoint is optimized for serving globally?
May I know did you enable any CDN things for this?
I tried by disabling cache in my chrome browser and see the result below.
It seems the blitz endpoint is taking more time than the website resources loading.
Also please note the installing deps like lodash takes more than 4 seconds! (See 2nd image below)
The speed of initialization outside the United States is very susceptible to network environment. Hopefully, you can allow custom CDN transit, or set the cache time of the API to extend, reducing the number of network requests for basic resources
@Thanga-Ganapathy 1.66s second for downloading only 69.1kB for webcontainer.js is pretty slow! :scream:
I'm curious, could you run:
curl -vv https://w-corp-staticblitz.com/cdn-cgi/trace
What do you get?
@Nemikolh Here is my output for the curl
$ curl -vv https://w-corp-staticblitz.com/cdn-cgi/trace
* processing: https://w-corp-staticblitz.com/cdn-cgi/trace
* Trying [2606:4700:3030::ac43:b86e]:443...
* Connected to w-corp-staticblitz.com (2606:4700:3030::ac43:b86e) port 443
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
* Server certificate:
* subject: CN=w-corp-staticblitz.com
* start date: Apr 13 00:42:33 2024 GMT
* expire date: Jul 12 00:42:32 2024 GMT
* subjectAltName: host "w-corp-staticblitz.com" matched cert's "w-corp-staticblitz.com"
* issuer: C=US; O=Let's Encrypt; CN=E1
* SSL certificate verify ok.
* using HTTP/2
* h2 [:method: GET]
* h2 [:scheme: https]
* h2 [:authority: w-corp-staticblitz.com]
* h2 [:path: /cdn-cgi/trace]
* h2 [user-agent: curl/8.2.1]
* h2 [accept: */*]
* Using Stream ID: 1
> GET /cdn-cgi/trace HTTP/2
> Host: w-corp-staticblitz.com
> User-Agent: curl/8.2.1
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/2 200
< date: Sat, 20 Apr 2024 10:39:32 GMT
< content-type: text/plain
< access-control-allow-origin: *
< server: cloudflare
< cf-ray: 877482d6ce79f0bf-CDG
< x-frame-options: DENY
< x-content-type-options: nosniff
< expires: Thu, 01 Jan 1970 00:00:01 GMT
< cache-control: no-cache
<
fl=538f25
h=w-corp-staticblitz.com
ip=2401:4900:232d:c08f:c1f2:1588:4495:72f0
ts=1713609572.927
visit_scheme=https
uag=curl/8.2.1
colo=CDG
sliver=none
http=http/2
loc=IN
tls=TLSv1.3
sni=plaintext
warp=off
gateway=off
rbi=off
kex=X25519
* Connection #0 to host w-corp-staticblitz.com left intact
@Thanga-Ganapathy Thanks a ton! Looks like we have indeed an issue. We'll keep you posted. :+1:
@Nemikolh I have the same problem, the web container is toooooo slow. Please consider use the cloudflare CDN.
Hey everyone! There's been a few changes to our infra. I'm curious to hear what it's like for today for @gwsbhqt and @Thanga-Ganapathy.
How long does it takes for you all to download those assets?
@Nemikolh thanks for the update.
This is on my decent internet connection speed, now it takes less than 5 seconds to boot the container initially and subsequent reloading the page also booting and installing packages a lot faster.
it seems to be network related issue getting resolved.
Hope it will continue in the future.
If that reflects everyone, i think the issue can be closed.
That's an excellent news! 😃 Thank you so much for checking.
I'll keep this issue for a bit to see if we get similar reports and then we can close it.