Recap of the Previous Post
In Part 4, I covered GAS and clasp. This time, I'll talk about Cloudflare Workers as the "next step beyond GAS."
When I Hit GAS's Limits
GAS is great, but push it hard enough and you'll hit walls.
- Execution time limit: Each run maxes out at 6 minutes. Heavy processes get cut off mid-way
- Concurrency limits: Performance degrades when multiple users access it simultaneously
- Response speed: WebApp cold starts are slow (sometimes taking several seconds)
These limitations became real problems as the Kagemusha System's user base grew.
What Are Cloudflare Workers? — A Quick Overview
Workers = a program execution environment that runs on servers around the world.
Cloudflare has servers in over 300 cities worldwide, and your program runs on the server closest to the user. That's why it's fast. And you never have to manage any servers (serverless).
This free tier is incredibly generous. Up to 100,000 requests per day at no cost. More than enough for solo development.
What Is wrangler? — The Deployment Tool for Workers
wrangler = a CLI tool for deploying (publishing) Cloudflare Workers.
Just as clasp was the deployment tool for GAS, wrangler is the deployment tool for Workers. Its job is to send the code you write on your PC to Cloudflare's servers.
Installation
wrangler also installs via npm.
npm install -g wrangler
For the first time, log in with your Cloudflare account:
wrangler login
# A browser window will open — authorize with your Cloudflare account
How I Use It — One Command to Deploy Worldwide
I mainly use two commands.
# Deploy (publish) Workers
wrangler deploy
# Run locally during development
wrangler dev
Running wrangler deploy distributes your code to servers in over 300 cities worldwide within seconds. I was genuinely amazed the first time I did this.
6-minute execution limit. Cold starts with multi-second waits. Concerns about concurrent access. After clasp push, you still needed to update the deployment on the GAS side.
No execution time worries. Millisecond-level responses. A single wrangler deploy publishes globally.
For the Kagemusha System, I migrated the API server portion from GAS to Workers. I didn't abandon GAS entirely — it still handles integration with Google services (spreadsheet operations and email sending). It's all about using the right tool for the job.
Next Time
Next up, I'll introduce the Stripe CLI for handling online payments. Dealing with money is nerve-wracking, but Stripe's robust testing environment made development surprisingly stress-free.
Part 2: Node.js & npm
Part 3: Git
Part 4: Google Apps Script & clasp
Part 5: Cloudflare Workers & wrangler
Part 6: Stripe CLI
Part 7: Python & Useful Libraries
Part 8: Wrap-Up — The Big Picture & How to Choose
Still managing tutor attendance manually?
Discover Kagemusha System