Live data from Hacker News

Running PHP fast at the edge with WebAssembly

wasmer.io

91–98 of 98 posts

Re: Running PHP fast at the edge with WebAssembly

#91
post #59

Earlier quoted context omitted.

I guess if you have a use case with higly cacheable data on edge, it might work great. For example, a form builder like typeform could cache form definitions on edge and render them close to users. Submissions would require db communication but the entire experience could be better. Otherwise it is just not worth it. BTW, I don’t even think PHP running slower in wasm would be that important. These things generally de…

> WASM is also pretty fast these days so.. ironically everything is petty fast and everyone waste that speed adding things that allow for a cheaper labour. wasm included. it went from a "have some expertly optimized code in the browser" to "just compile this hide cpp thing and ship as a react component" to then "it allows our servers to run any crap without knowledgeable staff in each language" we added so many Layer…

Ok hear this, I was toying with zig last week and compiled a quickjs wrapper that can run React and compiled that to wasm. So I have a JS runtime running wasm which runs quickjs runtime via zig and that runs React. Just trying to learn zig though but not much different than running PHP in WASM haha. Layers and layers of shit pressed together.

Re: Running PHP fast at the edge with WebAssembly

#92
post #84
post #63

Earlier quoted context omitted.

“Containers are not a sandboxing mechanism”, I hear reasonably often (although that seems surmountable at least in theory?). VMs are cheap, but not “let’s run thousands of them on ‘the edge’ in case we get a request for any of them!” cheap.

On kraft.cloud we can (done internal stress tests for this) run thousands of specialized VMs (aka unikernels) scaled to zero, meaning that when a request for one of them arrives we can wake it up and respond within the timescales of an RTT. You can take it out for a spin, just use the -0 flag when deploying to do scale to 0 ( https://docs.kraft.cloud/guides/features/scaletozero/ ).

Interesting – are we talking actual Linux VMs here, with binary-compatible syscalls etc., or something that applications need to be specifically built or packaged for in some way?

Re: Running PHP fast at the edge with WebAssembly

#93
post #91

Earlier quoted context omitted.

> WASM is also pretty fast these days so.. ironically everything is petty fast and everyone waste that speed adding things that allow for a cheaper labour. wasm included. it went from a "have some expertly optimized code in the browser" to "just compile this hide cpp thing and ship as a react component" to then "it allows our servers to run any crap without knowledgeable staff in each language" we added so many Layer…

Ok hear this, I was toying with zig last week and compiled a quickjs wrapper that can run React and compiled that to wasm. So I have a JS runtime running wasm which runs quickjs runtime via zig and that runs React. Just trying to learn zig though but not much different than running PHP in WASM haha. Layers and layers of shit pressed together.

will definitely use it as the wrapper that launches my electron app

Re: Running PHP fast at the edge with WebAssembly

#95

I think this will face the same problems as Next.js edge runtime: your database cannot be moved to the edge

There are already edge databases. Also, not everything requires a database.

Honest question, what kind of requests are you thinking of? In my projects I’m always fetching or changing data in a database on each request and if I’m not then I’m probably moving that logic to the frontend.

Re: Running PHP fast at the edge with WebAssembly

#96
post #88
post #45

Please stop calling it "at the edge." You have seven locations all in highly developed Equinix datacenters. Edge means getting embedded into ISP networks, cell towers, smaller metros, etc.

Actually it means both, in an unfortunate case of term overload. Though I can understand the embedded/IoT world being frustrated by this, as the term existed first within that context.

Both what? There is no definition other than running a workload "at the edge" near the requestor.

This is like the owner of a restaurant with two locations in the same city calling themselves a nationwide chain. It is just a flat out fabrication.

Re: Running PHP fast at the edge with WebAssembly

#97

Earlier quoted context omitted.

There are already edge databases. Also, not everything requires a database.

Honest question, what kind of requests are you thinking of? In my projects I’m always fetching or changing data in a database on each request and if I’m not then I’m probably moving that logic to the frontend.

A basic example is some compute service, say image transformation. You just run computations where all the input is in the request, and all the output goes to the response.

Re: Running PHP fast at the edge with WebAssembly

#98

Earlier quoted context omitted.

Honest question, what kind of requests are you thinking of? In my projects I’m always fetching or changing data in a database on each request and if I’m not then I’m probably moving that logic to the frontend.

A basic example is some compute service, say image transformation. You just run computations where all the input is in the request, and all the output goes to the response.

I feel like you still need to the DB for that, for auth at a minimum (which might not need to hit your main DB I guess) if not for logging (spend credit/record usage/just analytics). I guess all of that could be skipped with something like a JWT and log ETL process.

I'm intrigued by edge computing but the DB always seems like the bottleneck so thank you for the example.

Post reply on HN