SlideShare a Scribd company logo
1 of 28
Download to read offline
All contents © MuleSoft, LLC
Rust usage and adoption
in Flex Gateway
WASM beyond the browser
All contents © MuleSoft, LLC
Andres Testi Jorge Perez Leonardo Centurion
We are
LMTS @ Mulesoft AMTS @ Mulesoft
leocenturion
LMTS @ Mulesoft
andrestesti
jolisper
All contents © MuleSoft, LLC
What is Flex Gateway?
Flex Gateway is a lightway and cloud-friendly API Gateway, designed to manage
and secure APIs in standalone, integrate seamlessly with DevOps and CI/CD
workflows, or managed mode, via Anypoint control plane.
All contents © MuleSoft, LLC
What is Flex Gateway?
Technically speaking, we're not building an API gateway from scratch. We are
building an API Gateway controller that adapt configuration (either from files, APIs
or Anypoint Platform) to a particular gateway implementation: Envoy.
All contents © MuleSoft, LLC
Flex Gateway Overview
Anypoint
Policy
Engine
Envoy
Anypoint
Connector
Config
Language
Internal
Metrics
Ext
All contents © MuleSoft, LLC
Why Envoy?
● Adoption
● Simple Programmability Model
● Performance
● Portability
All contents © MuleSoft, LLC
Why Envoy?
● Extensibility
● Sandboxing
All contents © MuleSoft, LLC
How WASM fits in Reverse Proxies?
● Developed by major corporations (W3C, Mozilla, Microsoft, Google, Apple).
● Widely deployed.
● Portability.
● Many available programming languages (Rust, C/C++, TinyGo,
AssemblyScript).
● Safe extensibility due to sandboxing.
● Single-threaded by default.
● Plugin-oriented
● Binary format
All contents © MuleSoft, LLC
How Rust is bound to WASM? (FFI)?
● FFI extern functions are provide to call the host
● Rust must provide extern functions to be called by the host
● Proxy-wasm SDK provides a basic implementation of this interaction
All contents © MuleSoft, LLC
What is proxy-wasm?
● A standard platform for reverse proxies
● It includes an event oriented ABI
All contents © MuleSoft, LLC
WASM downsides?
● No garbage collector yet (Not an issue for Rust)
● Expensive host interaction, data must be serialized/deserialized into buffers
● Not all functionality is available (proxy-wasm is very limited, random
generators are broken)
● While there is an ad-hoc allocator (wee-alloc) for the linear memory, it is
limited due to restrictions of single threading and contiguous memory. It’s
suboptimal for intensive use.
All contents © MuleSoft, LLC
How is proxy-wasm related to WASI?
● Proxy-wasm predates WASI
● It was the first standardized ABI in WASM
● While there is some overlapping (e.g clock management), they are generally
complementary.
● WASI is a kind of POSIX standard, while proxy-wasm is focused on proxies.
● They can be used together in Envoy, since it supports a subset of WASI ABI.
All contents © MuleSoft, LLC
Pluggable Architecture
All contents © MuleSoft, LLC
Envoy supported WASM runtimes
● V8
● WASM Micro Runtime (by Byte Code Alliance)
● Wasmtime
● WAVM
All contents © MuleSoft, LLC
Why Event Loops?
● Single Threading.
● Scalability.
● Concurrency.
● Race conditions free.
All contents © MuleSoft, LLC
Life of a request
Backend
Filter
on_request_headers
Request to backend
on_request_body
Response from backend
on_response_headers
on_response_body
All contents © MuleSoft, LLC
Listener
subsystem
(Dispatcher)
Filter
proxy_on_http_request_headers
proxy_get_map
All contents © MuleSoft, LLC
proxy-wasm ABI
● The ABI defines a set of function headers for Host/Module interaction
● There are two kinds of functions:
○ Functions implemented by the Host
○ Functions implemented by the module
● Functions implemented by the Host are usually providers of information:
○ proxy_get_current_time()
○ proxy_log()
● Functions implemented by the module are usually used as event listeners
○ proxy_on_http_request_headers()
○ proxy_on_http_response_headers()
○ proxy_on_memory_allocate()
All contents © MuleSoft, LLC
Rust / proxy-wasm bootstrapping?
● Envoy calls the _start() function
● proxy_on_vm_start() is called when the virtual machine is started
● proxy_on_configure() is called when the config is updated
● proxy_on_context_created() is called when a new request is incoming
● Events are invoked in order (request headers, body, response headers, etc)
● proxy_on_done() is called when the request ends
All contents © MuleSoft, LLC
Communication with the host
All contents © MuleSoft, LLC
What proxy-wasm-sdk provides?
● extern “C” function headers
● A Dispatcher system for calling events
● A set of traits with default impls to define the event handlers
● Data serialization and deserialization between Host/Module boundaries
● RootContext, HtmlContext (L7) and StreamContext (L4) support
All contents © MuleSoft, LLC
Getting all headers
All contents © MuleSoft, LLC
Communication with the plugin
So the compiler won’t
change the name of the
function.
The host is expecting that
name
All contents © MuleSoft, LLC
The host calls
the plugin in the
root context
When an http request comes
another struct is used in a worker
thread
The previously created struct
handles the events that
correspond to that request and
the subsequent response
All contents © MuleSoft, LLC
Conclusion
● proxy-wasm is a safe, portable and performant extension mechanism.
● proxy-wasm and WASM itself are still in early stages.
● Programming model is still hard.
● Functionality is very restricted.
● Rust seems to be the best fit for WASM.
● The future is promising.
All contents © MuleSoft, LLC
Q&A
Q&A
All contents © MuleSoft, LLC
References
● Flex Gateway: https://www.mulesoft.com/platform/api/flex-api-gateway
● WASM: https://webassembly.org
● WASI: https://github.com/WebAssembly/WASI
● Proxy WASM: https://github.com/proxy-wasm/proxy-wasm-rust-sdk
● Envoy: https://www.envoyproxy.io
All contents © MuleSoft, LLC
Thank you

More Related Content

Similar to WASM Beyond the Browser [2022_07_21 meetup]

MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustMuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustJitendra Bafna
 
Cwin16 tls-a micro-service deployment - v1.0
Cwin16 tls-a micro-service deployment - v1.0Cwin16 tls-a micro-service deployment - v1.0
Cwin16 tls-a micro-service deployment - v1.0Capgemini
 
Mulesoftmeetup Thiruvanathapuram #4
Mulesoftmeetup Thiruvanathapuram #4Mulesoftmeetup Thiruvanathapuram #4
Mulesoftmeetup Thiruvanathapuram #4Anurag Dwivedi
 
OSGi Cloud Ecosystems - David Bosschaert
OSGi Cloud Ecosystems - David BosschaertOSGi Cloud Ecosystems - David Bosschaert
OSGi Cloud Ecosystems - David Bosschaertmfrancis
 
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3Alfonso Martino
 
On prem to cloud hub migration (updated)
On prem to cloud hub migration (updated)On prem to cloud hub migration (updated)
On prem to cloud hub migration (updated)Sandeep Deshmukh
 
Mulesoft Meetup Milano #9 - Batch Processing and CI/CD
Mulesoft Meetup Milano #9 - Batch Processing and CI/CDMulesoft Meetup Milano #9 - Batch Processing and CI/CD
Mulesoft Meetup Milano #9 - Batch Processing and CI/CDGonzalo Marcos Ansoain
 
MuleSoft_NZ_Meetup_9
MuleSoft_NZ_Meetup_9MuleSoft_NZ_Meetup_9
MuleSoft_NZ_Meetup_9MizuhoHoshino
 
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...Jitendra Bafna
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudLyzun Oleksandr
 
Bootify Yyour App from Zero to Hero
Bootify Yyour App from Zero to HeroBootify Yyour App from Zero to Hero
Bootify Yyour App from Zero to HeroEPAM
 
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020Royston Lobo
 
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)David Bosschaert
 
Mule soft cloudhub deployment basics
Mule soft cloudhub deployment basicsMule soft cloudhub deployment basics
Mule soft cloudhub deployment basicsArun Yaligar
 
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...Jitendra Bafna
 
Virtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelVirtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelJimmy Attia
 
OSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David BosschaertOSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David Bosschaertmfrancis
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsChris Bailey
 

Similar to WASM Beyond the Browser [2022_07_21 meetup] (20)

Madrid meetup #7 deployment models
Madrid meetup #7   deployment modelsMadrid meetup #7   deployment models
Madrid meetup #7 deployment models
 
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustMuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
 
Cwin16 tls-a micro-service deployment - v1.0
Cwin16 tls-a micro-service deployment - v1.0Cwin16 tls-a micro-service deployment - v1.0
Cwin16 tls-a micro-service deployment - v1.0
 
Mulesoftmeetup Thiruvanathapuram #4
Mulesoftmeetup Thiruvanathapuram #4Mulesoftmeetup Thiruvanathapuram #4
Mulesoftmeetup Thiruvanathapuram #4
 
OSGi Cloud Ecosystems - David Bosschaert
OSGi Cloud Ecosystems - David BosschaertOSGi Cloud Ecosystems - David Bosschaert
OSGi Cloud Ecosystems - David Bosschaert
 
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 3
 
On prem to cloud hub migration (updated)
On prem to cloud hub migration (updated)On prem to cloud hub migration (updated)
On prem to cloud hub migration (updated)
 
Mulesoft Meetup Milano #9 - Batch Processing and CI/CD
Mulesoft Meetup Milano #9 - Batch Processing and CI/CDMulesoft Meetup Milano #9 - Batch Processing and CI/CD
Mulesoft Meetup Milano #9 - Batch Processing and CI/CD
 
MuleSoft_NZ_Meetup_9
MuleSoft_NZ_Meetup_9MuleSoft_NZ_Meetup_9
MuleSoft_NZ_Meetup_9
 
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...
MuleSoft Surat Virtual Meetup#25 - Anypoint Platform Features and Capabilitie...
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 
Bootify Yyour App from Zero to Hero
Bootify Yyour App from Zero to HeroBootify Yyour App from Zero to Hero
Bootify Yyour App from Zero to Hero
 
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
 
Node.js Tools Ecosystem
Node.js Tools EcosystemNode.js Tools Ecosystem
Node.js Tools Ecosystem
 
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
 
Mule soft cloudhub deployment basics
Mule soft cloudhub deployment basicsMule soft cloudhub deployment basics
Mule soft cloudhub deployment basics
 
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
 
Virtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelVirtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment model
 
OSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David BosschaertOSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David Bosschaert
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs Nodejs
 

Recently uploaded

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Recently uploaded (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

WASM Beyond the Browser [2022_07_21 meetup]

  • 1. All contents © MuleSoft, LLC Rust usage and adoption in Flex Gateway WASM beyond the browser
  • 2. All contents © MuleSoft, LLC Andres Testi Jorge Perez Leonardo Centurion We are LMTS @ Mulesoft AMTS @ Mulesoft leocenturion LMTS @ Mulesoft andrestesti jolisper
  • 3. All contents © MuleSoft, LLC What is Flex Gateway? Flex Gateway is a lightway and cloud-friendly API Gateway, designed to manage and secure APIs in standalone, integrate seamlessly with DevOps and CI/CD workflows, or managed mode, via Anypoint control plane.
  • 4. All contents © MuleSoft, LLC What is Flex Gateway? Technically speaking, we're not building an API gateway from scratch. We are building an API Gateway controller that adapt configuration (either from files, APIs or Anypoint Platform) to a particular gateway implementation: Envoy.
  • 5. All contents © MuleSoft, LLC Flex Gateway Overview Anypoint Policy Engine Envoy Anypoint Connector Config Language Internal Metrics Ext
  • 6. All contents © MuleSoft, LLC Why Envoy? ● Adoption ● Simple Programmability Model ● Performance ● Portability
  • 7. All contents © MuleSoft, LLC Why Envoy? ● Extensibility ● Sandboxing
  • 8. All contents © MuleSoft, LLC How WASM fits in Reverse Proxies? ● Developed by major corporations (W3C, Mozilla, Microsoft, Google, Apple). ● Widely deployed. ● Portability. ● Many available programming languages (Rust, C/C++, TinyGo, AssemblyScript). ● Safe extensibility due to sandboxing. ● Single-threaded by default. ● Plugin-oriented ● Binary format
  • 9. All contents © MuleSoft, LLC How Rust is bound to WASM? (FFI)? ● FFI extern functions are provide to call the host ● Rust must provide extern functions to be called by the host ● Proxy-wasm SDK provides a basic implementation of this interaction
  • 10. All contents © MuleSoft, LLC What is proxy-wasm? ● A standard platform for reverse proxies ● It includes an event oriented ABI
  • 11. All contents © MuleSoft, LLC WASM downsides? ● No garbage collector yet (Not an issue for Rust) ● Expensive host interaction, data must be serialized/deserialized into buffers ● Not all functionality is available (proxy-wasm is very limited, random generators are broken) ● While there is an ad-hoc allocator (wee-alloc) for the linear memory, it is limited due to restrictions of single threading and contiguous memory. It’s suboptimal for intensive use.
  • 12. All contents © MuleSoft, LLC How is proxy-wasm related to WASI? ● Proxy-wasm predates WASI ● It was the first standardized ABI in WASM ● While there is some overlapping (e.g clock management), they are generally complementary. ● WASI is a kind of POSIX standard, while proxy-wasm is focused on proxies. ● They can be used together in Envoy, since it supports a subset of WASI ABI.
  • 13. All contents © MuleSoft, LLC Pluggable Architecture
  • 14. All contents © MuleSoft, LLC Envoy supported WASM runtimes ● V8 ● WASM Micro Runtime (by Byte Code Alliance) ● Wasmtime ● WAVM
  • 15. All contents © MuleSoft, LLC Why Event Loops? ● Single Threading. ● Scalability. ● Concurrency. ● Race conditions free.
  • 16. All contents © MuleSoft, LLC Life of a request Backend Filter on_request_headers Request to backend on_request_body Response from backend on_response_headers on_response_body
  • 17. All contents © MuleSoft, LLC Listener subsystem (Dispatcher) Filter proxy_on_http_request_headers proxy_get_map
  • 18. All contents © MuleSoft, LLC proxy-wasm ABI ● The ABI defines a set of function headers for Host/Module interaction ● There are two kinds of functions: ○ Functions implemented by the Host ○ Functions implemented by the module ● Functions implemented by the Host are usually providers of information: ○ proxy_get_current_time() ○ proxy_log() ● Functions implemented by the module are usually used as event listeners ○ proxy_on_http_request_headers() ○ proxy_on_http_response_headers() ○ proxy_on_memory_allocate()
  • 19. All contents © MuleSoft, LLC Rust / proxy-wasm bootstrapping? ● Envoy calls the _start() function ● proxy_on_vm_start() is called when the virtual machine is started ● proxy_on_configure() is called when the config is updated ● proxy_on_context_created() is called when a new request is incoming ● Events are invoked in order (request headers, body, response headers, etc) ● proxy_on_done() is called when the request ends
  • 20. All contents © MuleSoft, LLC Communication with the host
  • 21. All contents © MuleSoft, LLC What proxy-wasm-sdk provides? ● extern “C” function headers ● A Dispatcher system for calling events ● A set of traits with default impls to define the event handlers ● Data serialization and deserialization between Host/Module boundaries ● RootContext, HtmlContext (L7) and StreamContext (L4) support
  • 22. All contents © MuleSoft, LLC Getting all headers
  • 23. All contents © MuleSoft, LLC Communication with the plugin So the compiler won’t change the name of the function. The host is expecting that name
  • 24. All contents © MuleSoft, LLC The host calls the plugin in the root context When an http request comes another struct is used in a worker thread The previously created struct handles the events that correspond to that request and the subsequent response
  • 25. All contents © MuleSoft, LLC Conclusion ● proxy-wasm is a safe, portable and performant extension mechanism. ● proxy-wasm and WASM itself are still in early stages. ● Programming model is still hard. ● Functionality is very restricted. ● Rust seems to be the best fit for WASM. ● The future is promising.
  • 26. All contents © MuleSoft, LLC Q&A Q&A
  • 27. All contents © MuleSoft, LLC References ● Flex Gateway: https://www.mulesoft.com/platform/api/flex-api-gateway ● WASM: https://webassembly.org ● WASI: https://github.com/WebAssembly/WASI ● Proxy WASM: https://github.com/proxy-wasm/proxy-wasm-rust-sdk ● Envoy: https://www.envoyproxy.io
  • 28. All contents © MuleSoft, LLC Thank you