Ah... I had understood it was some level of bytecode interpretation (see:
https://www.solo.io/blog/the-state-of-webassembly-in-envoy-proxy/), hence
wanting to explore WAVM to ensure that we are getting the best out of our
extension. If this is a false assumption, then it may not be worth pushing to
get the WAVM version working. I am still happy to help work this through if it
would help.
As to results. This is a PoC of an authorization service we want to build. I
am exploring different approaches before building out the solution. The
extension needs to authorize HTTP requests, but authz is based on external
state which needs to be captured and maintained in the extension. Because of
the lack of state sharing between WASM VMs, I need two extensions: one on the
HTTP worker threads to handle requests, and one running as a global service
extension. They talk to each other over message queues.
I want to compare this design against a traditional external authz sidecar
(which is much easier to build!) to determine if the performance gains are
worth the extra development cost and complexity.
The setup is comparing the traditional external authz extension with my WASM
extension.
* External authz is configured to call a trivial localhost service (in a
different container on the same host) which always returns a 200 status...
so allows the request through.
* The WASM is composed of two parts:
- The core (service) extension which accepts messages on a message queue.
For now, this service simply responds to messages by sending a response on
the designated response queue (nominated in the request).
- An http worker extension which intercepts HTTP requests and sends a
message to the core service and awaits a response before continuing (or
failing) the HTTP request. On startup this extension negotiates a unique
queue name (using the shared key/value store) so that the core service
knows where (which HTTP worker thread) to send its responses.
This is the bare bones of the communication flow and should enable us to
determine the potential upside of the extension vs external authz.
I saw the following performance (running in Rancher Desktop on my laptop,
using docker image envoyproxy/envoy:v1.19.1, v8 WASM runtime, the WASM is
authored in AssemblyScript, load generated using Apache JMeter running
locally, 100 threads x100 requests = 10k in total):
- ext_authz: 620 req/s
- WASM queue: 660 req/s +6%
- no authz: 1040 req/s +70%
So, not very promising.
By staying "in-process" I was hoping to see results closer to the no authz
numbers, e.g. pushing 800 req/s.