Skip to content

Lab 12: a quicknotes endpoint as a wasm component on spin#1332

Open
Dekart-hub wants to merge 3 commits into
inno-devops-labs:mainfrom
Dekart-hub:feature/lab12
Open

Lab 12: a quicknotes endpoint as a wasm component on spin#1332
Dekart-hub wants to merge 3 commits into
inno-devops-labs:mainfrom
Dekart-hub:feature/lab12

Conversation

@Dekart-hub

Copy link
Copy Markdown

Goal

Build one QuickNotes-style endpoint (Moscow time as JSON) as a WebAssembly component with the Spin Go SDK, measure it against the Lab 6 Docker container, and (bonus) rebuild the same logic as a standalone WASI CLI module under bare wasmtime to contrast the two execution models.

Changes

  • wasm/: the Spin component, scaffolded with spin new -t http-go (Spin 3.6.3, TinyGo 0.41.1, SDK spinframework/spin-go-sdk/v2 v2.2.1)
    • main.go: spinhttp.Handle handler returning unix, iso, hour_minute and the timezone as JSON; Moscow via time.FixedZone because TinyGo ships no tzdata
    • spin.toml: route scoped to /time, allowed_outbound_hosts = [], scaffold's wasip1 -buildmode=c-shared build command untouched
  • wasm-cli/ (bonus): the same logic as a no-SDK WASI command module in the CGI/WAGI shape (request from env vars, headers plus JSON to stdout) for wasmtime run
  • submissions/lab12.md: build and curl evidence, the full perf table, both execution models compared, design questions a-j

Testing

  • spin build produces a 0.53 MB main.wasm; spin up serves /time with valid Moscow-time JSON (200, application/json, RFC3339 with +03:00); POST gets 405, unrouted paths get 404
  • Perf vs the Lab 6 container on the same machine: warm p50 0.59 ms vs 1.87 ms (curl time_total, 50 runs), cold start median 57 ms vs 121 ms (5 samples, launch to first 200), artifact 0.53 MB vs 21.6 MB
  • Design-question experiments run for real: dropping -buildmode=c-shared fails the link (the scaffold has no func main), the Spin component under bare wasmtime run exits silently as a reactor, and wasmtime serve refuses the core module
  • Bonus module: wasmtime run --env REQUEST_METHOD=GET --env PATH_INFO=/time prints the same JSON; per-invocation p50 6.0 ms vs 0.59 ms from the warm Spin server

Checklist

  • Title is a clear sentence (<= 70 chars)
  • Commits are signed (git log --show-signature)
  • submissions/lab12.md updated

Signed-off-by: Aleksandr <55945487+Dekart-hub@users.noreply.github.com>
Signed-off-by: Aleksandr <55945487+Dekart-hub@users.noreply.github.com>
Signed-off-by: Aleksandr <55945487+Dekart-hub@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant