DEV Community

Cover image for How I Built a Cloud Environment Provisioning Workflow That Takes 7–15 Seconds
Harun - solo dev
Harun - solo dev

Posted on Edited on

How I Built a Cloud Environment Provisioning Workflow That Takes 7–15 Seconds

Every architectural decision in HYNA-Stage was forced by one constraint: I build on a $150 Android phone in Termux.

Not a laptop with Docker Desktop. Not a machine where I can run deno test locally. A phone, with a few GB of free storage and no container daemon.

That sounds like a limitation. It turned out to be the thing that made the architecture simple.

Here's what I built, and why each piece is the shape it is.


🧱 DECISION 1: COMPUTE — MICROVMs, NOT CONTAINERS

I couldn't run Docker locally, so local containers were never an option. But even if I could, I didn't want them for this.

Containers share a kernel. For a platform where strangers run arbitrary code, that's a boundary I'd have to defend constantly. So compute is E2B Firecracker MicroVMs — hardware-virtualised, own kernel, ephemeral by default.

The trade-off is honest: a real kernel boot costs real seconds. That's most of why cold starts are 7–15s and not instant.


⚙️ DECISION 2: CONTROL PLANE — EDGE FUNCTIONS I DEPLOY WITH CURL

Supabase gives me Postgres, Auth, and Deno Edge Functions in one place. But Deno doesn't run in Termux, so I can't serve or test functions locally.

So my deploy loop is a curl call to the Management API:

curl -X POST \
  "https://api.supabase.com/v1/projects/$REF/functions/deploy" \
  -H "Authorization: Bearer $SUPABASE_PAT" \
  -F "file=@supabase/functions/deploy-stage/index.ts"
Enter fullscreen mode Exit fullscreen mode

No local runtime, no watch mode, no emulator. I write the function, push it, and test it live. Slower feedback loop — but it forced me to keep functions small enough to reason about in one read.


🌐 DECISION 3: ROUTING — A WORKER, NOT A LOAD BALANCER

Sandbox URLs route through a Cloudflare Worker. It's the piece I could actually run and iterate on from a phone, and it means I never had to think about provisioning a load balancer or managing TLS certs.


🎨 DECISION 4: FRONTEND — NO BUILD STEP AT ALL

Vanilla HTML, Tailwind via CDN, vanilla JS. No React, no bundler, no npm run build.

Not because frameworks are bad. Because a build pipeline on a phone is friction I'd pay every single deploy. Static files I can edit and zip and upload are friction I pay zero times.

The whole production site is 14 files and 163 KB zipped.


💥 WHAT BROKE, AND WHAT IT TAUGHT ME

Zombie sandboxes. My first version let sandboxes pause on timeout instead of dying. Users closed their tabs and I kept paying for compute nobody was using.

Fix: hard-kill at creation, plus a database sweep as a second line of defence.

Sandbox.create({ lifecycle: { onTimeout: "kill" } })
Enter fullscreen mode Exit fullscreen mode
-- pg_cron: flip anything still 'running' past its expiry
UPDATE sandbox_sessions
SET status = 'expired', ended_at = started_at + make_interval(secs => ttl_seconds)
WHERE status IN ('running','pending')
  AND now() > started_at + make_interval(secs => ttl_seconds);
Enter fullscreen mode Exit fullscreen mode

A quota check that didn't reserve anything. I wrote a function that checked limits and returned a boolean — then created the sandbox afterwards. Between the check and the insert there's a multi-second window. Ten parallel requests could all pass.

Fix: take a per-user advisory lock and write a reservation row inside the same transaction. The check and the claim have to be one atomic act, or the check is decorative.

Both of these came from someone poking at the platform, not from me being clever.


⏱️ WHERE THE SECONDS GO

The 7–15s range isn't padding. It's a stack:

  • MicroVM boot — a real kernel, not a cloned namespace
  • Runtime readiness inside the VM
  • Your dependency install — the biggest variable, and the one I control least

A bare Node script and a Kotlin project with a cold Gradle cache are not the same workload. That's why the title says a range. My homepage used to say "5 Seconds" until a commenter pointed out my own blog contradicted it. He was right, and the number is gone.


🛑 WHAT I DIDN'T BUILD

  • No offline mode. No connection, no sandbox.
  • No persistence by default. Push to Git before the TTL or it's gone.
  • No production hosting. Prototyping and isolated testing only.
  • No egress allowlist yet. Sandboxes have unrestricted outbound network access. Fine for supervised prototyping, not yet for unattended agents. That warning now sits beside the setup instructions on the site, because an isolated filesystem is not an isolated network.

🔨 WANT TO TIME IT YOURSELF?

One tester has already signed up to check that 7–15s range against a stopwatch, on Kotlin, on a real budget Android phone. I want four more.

npm install -g @hynaweb/stage
hyna-stage init go     # pick something that isn't node
Enter fullscreen mode Exit fullscreen mode

Comment with the runtime you'll break and the number you actually measure. Bad numbers are still useful numbers.

— Harun, Founder & CEO, HYNAWEB 🐯☁️

Top comments (11)

Collapse
 
koda2026 profile image
Harun - solo dev • • Edited

@akhourianmolkumar ,@effessdev , @xulingfeng , @nyaomaru , @star123 , @forkcount , @hubedav WHAT DO YOU THINK GUYS 👫👫

Collapse
 
technogamerz profile image
𝐓𝐡𝐞 𝐋𝐚𝐳𝐲 𝐆𝐢𝐫𝐥 •

👀

Collapse
 
koda2026 profile image
Harun - solo dev •

🚀🔥👋

Thread Thread
 
xulingfeng profile image
xulingfeng •

👏

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Brooo new organization

Thread Thread
 
xulingfeng profile image
xulingfeng •

不是,你们咋突然都开始搞起组织了😕

Thread Thread
 
koda2026 profile image
Harun - solo dev •

BRO I DONT KNOW IT FELT THE WAY!

Thread Thread
 
xulingfeng profile image
xulingfeng •

Fair enough, sometimes you just follow that gut feeling.

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Yep bro

Collapse
 
nyaomaru profile image
nyaomaru •

👍

Collapse
 
koda2026 profile image
Harun - solo dev •

@akhourianmolkumar ,@effessdev , @xulingfeng , @nyaomaru , @star123 , @forkcount , @hubedav GUYS JUST MADE A ORGANIZATION OUR NEW POSTS COMES UNDER THAT 🔥🚀🚀🚀🚀🔥🔥🔥🔥🔥