What is WebAssembly?
WebAssembly (also known as WASM) is an assembly-like language that allows code written in compiled languages—such as C, C++, Go, Rust, and many others—to run at near-native speed on the Web. WebAssembly provides some key features for web development:
- It’s fast and efficient, since it’s designed to be decoded and run in binary format;
- It’s secure, as it runs in sandboxes;
- It’s open and debuggable, since it’s available in text format;
- It’s part of the Open Web Platform.
Modernize Your Applications Using WebAssembly
Today’s hyper-connected economy demands superior digital experiences and faster innovation. Running applications on a modern, distributed edge computing platform is a perfect path to realize that vision. However, most sophisticated applications are written in compiled languages to run on legacy infrastructures like the cloud or on-prem. These applications can’t run on the edge, which typically supports interpreted languages.
So the question developers face is: how can they quickly modernize legacy applications to run on edge computing platforms?
WebAssembly provides a much better, simpler, and faster alternative to application modernization. With WASM, existing code only needs to be recompiled for the edge without any need to rewrite code in a new, unfamiliar language. This modernization process can be further accelerated by deploying these applications on the high-performance and secure NoOps Azion Edge Platform.
How to Use WebAssembly on the Azion Platform
Let’s use a practical example to demonstrate how easily a legacy application can be modernized using WASM on the Azion Edge Platform.
Image transformation is a critical component of e-commerce applications. It requires serious processing power to deliver proper quality images that preserve user experience while simultaneously improving performance and reducing bandwidth costs.
To run the example code on the Azion Edge Platform, you first need to compile your original code into WASM format and then convert the obtained code into bytes. For this purpose, you can use a Shell script like this:
od -An -v -t uC <YOUR_WASM_CODE>.wasm \
| sed -e "s/^[[:blank:]]*//g;s/[[:blank:]]*$//g" \
-e "s/[[:blank:]][[:blank:]]*/\n/g" \
| tr '\n' ',' \
| sed -e "s/,*$//g" > <BYTES_RESULT>.txt
This step generates a byte code output that looks like this:
The WASM code can now be directly invoked from an edge function, as shown below (you can follow the detailed instructions in our documentation).
The edge function can now be instantiated and executed at every edge location on the Azion platform. And that’s it! In just a few minutes, you’ve brought your complete application from the centralized data center to the Azion edge, without compromising speed while simultaneously improving your application’s scalability, availability, and security.
Moving to the Edge Has Never Been Easier
In this blog post, we demonstrated how adopting WebAssembly can transform the way you build and run your applications faster and more effectively at the edge. But that’s just a small taste of what you can do with WASM on the Azion Edge Platform.
You can keep learning about all WASM possibilities for developing edge functions by checking our documentation. You can also sign up for free to test these and all the other features we offer to power your business and help you build future-proof serverless applications.
All new accounts include:
- $300 worth of service credits, valid for 12 months
- Full access to all products and features
- Deploying your first edge application, which takes less than five seconds
- Free onboarding session
And all with no credit card registration.