In My Last Post, I gave an 101 Introduction To WebAssembly,but if you noticed, I only talked about WebAssembly in context of the Web.
Today, I'll dive into the whole new realm of using WebAssembly outside of the Web Browser.
So, Let's begin
Let us have a Recap first:
So, What is WebAssembly?
Then, in 2017 something phenomenal came into picture which is
WebAssembly. At a very superficial level, you can think of
WebAssembly as an another language which can be executed inside our Web Browser.
Now, Let's jump onto our Main topic of the day, which is
Making Use of WebAssembly outside of Web Browsers
Let us try to understand it with the help of an Example:
Let us Assume that we want to build an Application X and the main purpose of this Application is to perform some sort Of Data Analysis.
Now, Let's have a look at it's architecture:
Now, This approach of constructing our application works but there is an issue. Every time when you want to perform analysis on some of your data, you will have to manually push your data to the Server, which consumes a lot of time and also does heavy processing at the Backend/(Server Side would be a more relevant technical term for this)
Why, not switch to some another approach where instead of relying on any external infrastructure services for our server, we can do it in our browser itself.
For this approach, let's assume that we know nothing about WebAssembly.
Now, this is where our Saviour WebAssembly comes into Picture
Now, the advantage over here is that now you have a much faster interface and you can reuse existing code and essentially just every time that library updates, you can compile it and then use it.
The downside though is that, anytime that you are making use of WebAssembly, there will be some nuance of complexity that will get introduced to your Application.
Now, let's explore what it would look like to have a Serverless Architecture
Now, under this approach, Working on the Frontend Side remains the same as previous 3 approaches, the only change here is that for the analysis part we are adopting a Serverless based approach.
Now, for implementing this Serverless approach, we can make use of Fastly
Fastly makes use of WebAssembly RunTime, meaning now we can deploy our C Library code to it, and it will get transpiled to WebAssembly binary and then thus can be interpreted.
You might also think that, Why not make use of any Traditional Cloud Service Provider like AWS, Azure or Google Cloud Platform(GCP) for deploying our code.
Well, there are 2 reasons for not using any Cloud Service Provider:
1) Initialisation Time and Compatibility issues:
First of all, if we deploy our function to any traditional Cloud based service provider, it will take a lot of time for our function to spin up and concurrently accept API Requests from Users.
Since most of the Cloud Based Service providers make use of Containers, it kind of becomes messy to use them for building out our Application.
Secondly, the WASM Runtime is currently undergoing a lot of R&D for the traditional cloud based service providers, so using them here will not make sense for our purpose.
Now, if you look at our demonstration picture as well for Approach Number 4, it only takes 35 Nano Seconds for our Function to spin up and start accepting API Requests from Users.
Thus, it is very time effective to go for this Serverless Approach.
So, as you see the Use Of WebAssembly is not limited to using it in our WebBrowser only, it extends much beyond that as I explained you in Today's post with the help of an Example.
See you in the Next Post :)
Latest comments (0)