Live data from Hacker News

Running PHP fast at the edge with WebAssembly

wasmer.io

1–10 of 98 posts

Re: Running PHP fast at the edge with WebAssembly

#3
This is trying to solve a solved problem with lots of difficult technology that doesn't apply here. Most of the PHP websites are WordPress. The solution to have a speedy WordPress site is to compile it to static HTML. Calls to the server should happen with JavaScript. The server will always remain relevant as WordPress uses a Database and thus the "Edge" makes no sense here.

Re: Running PHP fast at the edge with WebAssembly

#4
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!

Re: Running PHP fast at the edge with WebAssembly

#6
post #3

This is trying to solve a solved problem with lots of difficult technology that doesn't apply here. Most of the PHP websites are WordPress. The solution to have a speedy WordPress site is to compile it to static HTML. Calls to the server should happen with JavaScript. The server will always remain relevant as WordPress uses a Database and thus the "Edge" makes no sense here.

Getting WordPress running in WASM was a huge milestone. It was one of the first big PHP/WASM achievements, but was never the end goal, just a proof-of-concept. The target market for this tech is not WordPress bloggers.

Re: Running PHP fast at the edge with WebAssembly

#7
post #5

I'm still trying to understand what this does and what's the use case. Is the "edge" a server? The browser? Why should I compile WordPress or Laravel to wasm?

In this context the edge is a fancy word to say "serverless". It just means that your PHP interpreter will be started on-demand on a node closer to your customer's request.

So if your website receives no requests, it costs you nothing. And requests have less latency for the user.

That's the theory anyway, in my experience reality is a lot more nuanced because the serverless node still has to reach a database and so on.

Re: Running PHP fast at the edge with WebAssembly

#8
post #5

I'm still trying to understand what this does and what's the use case. Is the "edge" a server? The browser? Why should I compile WordPress or Laravel to wasm?

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 one use case. Another is that WASM makes PHP portable, in the sense it can run in any web browser without the need for a back-end server. Lots of potential opportunities for distributing software which runs completely locally.

Re: Running PHP fast at the edge with WebAssembly

#9
post #2

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

Nb PHP is already really fast. Some major things built on it are slow, mostly due to things like poor data access patterns or architecture, but its culture since the beginning has basically been “get out of PHP and into C as fast as possible” and it shows (this is basically the trick to any scripting language “being fast”, PHP just embraced it hard from the very beginning).

If you’re on PHP and need more speed in the language itself, basically every other scripting language (yes, including Node) is off the table immediately. Lateral move at best.

(All that to say, yeah, I entirely expected that the headline would lead to an article about making PHP slower)

Post reply on HN