Performance is slow on HTTP Trigger
Issue
I appear to have quite some overhead caused by Spin. I compiled an application as a WASM package and benchmark the HTTP speed against a native class instance and get the below performance for my calls:
Is there any good practice on speeding this up? Can the HTTP connection be re-used?
Python
Typescript
General
- Spin version (
spin --version): spin 2.2.0 (eebfae1 2024-01-30) - Installed plugin versions (
spin plugins list --installed)
cloud 0.7.0 [installed]
js2wasm 0.6.1 [installed]
py2wasm 0.3.2 [installed]
cc @karthik2804
@XavierGeerinck thanks for reporting this. It's hard to guess what the bottleneck(s) are without profiling -- it could be some combination of network, Wasm instantiation, or function invocation overhead. I did some of my own benchmarking a while back (which deliberately omitted the networking aspect since that can be highly variable) and was seeing about 0.5 ms average execution times for a simple Python app. A lot has happened since then, though: we've moved from spin-http to wasi-http and deprecated py2wasm in favor of componentize-py. One or more of those changes could have caused performance regressions.
Would you mind sharing the steps and code you used to run your benchmarks? Having a reproduceable test case that we could profile would help a lot here.