Live data from Hacker News

Running PHP fast at the edge with WebAssembly

wasmer.io

31–40 of 98 posts

Re: Running PHP fast at the edge with WebAssembly

#31
post #27

Earlier quoted context omitted.

What I usually do is that I use two hostnames. host1 for http requests which can be cached. That host is behind a CDN. host2 for HTTP requests which can't be cached. That host points directly to my server. Are you saying it would result in a better user experience when I only use host1 which is behind the CDN and add no-cache headers to the request that can't be cached?

It's complicated but typically yes. The simplest reason is that TCP+TLS handshakes require multiple round trips for a fresh connection. The CDN can maintain a persistent connection to the backend that is shared across users. It is also likely that the CDN to backend connection goes over a better connection than the user to backend connection would.

Very interesting, thanks. That would make my setup even simpler.

Re: Running PHP fast at the edge with WebAssembly

#32
post #19
post #8

Earlier quoted context omitted.

The “edge” in this case is the browser (from a pure WASM standpoint, though I see these guys also offer a hosted serverless version too). For most general-purpose applications, there’s no point to WASM. But some apps may run specific functions which take a long time (e.g. bulk/batch processing), and being able to execute those tasks securely on the client side provides immediate feedback and better UX. That’s just on…

The browser is not the "edge". The browser is the browser. Running WordPress in the browser makes exactly zero sense. Only exception if you are running a test instance.

https://wordpress.org/playground/

Re: Running PHP fast at the edge with WebAssembly

#33
Can someone ELI5 what is does "edge" computing means?

The way I understand it is that is moving some operations closer to the client to avoid bandwidth costs and improve performance.

I thought of the Tesla car computer as edge computing, as it does a lot of processing within the car that would otherwise add latency and reliance on a internet connection.

But for web browsers? Going to some websites?

What sort of apps need this functionality?

Seems like over-engineering, so I'm looking for someone to explain me.

Re: Running PHP fast at the edge with WebAssembly

#34
post #16

Let me try to understand this "Edge" thing: - The user sends an HTTP request to somesite.com - Their DNS query for somesite.com gets resolved to some datacenter near them - The HTTP request arrives at the datacenter where the PHP in WebAssembly is executed at half the speed of native PHP - The PHP in Webassembly sends database queries to a central DB server over the internet - The PHP in Webassembly templates the dat…

[deleted]

Re: Running PHP fast at the edge with WebAssembly

#36

Can someone ELI5 what is does "edge" computing means? The way I understand it is that is moving some operations closer to the client to avoid bandwidth costs and improve performance. I thought of the Tesla car computer as edge computing, as it does a lot of processing within the car that would otherwise add latency and reliance on a internet connection. But for web browsers? Going to some websites? What sort of apps…

Hi, traditionally for our purposes it solved a few problems.

1. latency

2. intermittent access

3. distributed "meaningful" data preparation/filters

One may consider routers with squid proxies, VoIP trunks, and p2p cache are essentially similar "edge" technologies.

There are additional use-cases, but we don't want to educate the lamers stealing resumes off jobs sites... having no clue what they are talking about.

Have a nice day, =)

Re: Running PHP fast at the edge with WebAssembly

#37
post #16

Let me try to understand this "Edge" thing: - The user sends an HTTP request to somesite.com - Their DNS query for somesite.com gets resolved to some datacenter near them - The HTTP request arrives at the datacenter where the PHP in WebAssembly is executed at half the speed of native PHP - The PHP in Webassembly sends database queries to a central DB server over the internet - The PHP in Webassembly templates the dat…

That's a valid concern, and with a classical centralized DB the Edge solution will not be faster in many cases, especially considering how many DB requests some ORMs like Drupal or Wordpress need for each page load... Some other providers have tried to solve the problem with replicated databases that are used for local reads. I can't go into details yet, but Wasmer will offer a solution for this problem quite soon as…

https://electric-sql.com/ ?

Re: Running PHP fast at the edge with WebAssembly

#38
post #2

Whereby fast is "About half the speed of native PHP"

Author here. Faster than it has ever been in the Edge via WebAssembly :) But you are completely right pointing out that there's still some room to improve, specially when compared to running PHP natively. Right now there's some price to pay for the isolation and sandboxing, but we are working hard to reduce the gap to zero. Stay tuned for more updates on this front!

Given that we run PHP on the edge, what is the point of running the PHP interpreter on top of a WebAssembly interpreter (Wasmer) instead of just running the PHP interpreter directly?

The latter will always be faster.

Post reply on HN