[AI in Action] Rewriting a Daily LINE Bot from Python to Go 1.26 on Cloud Run
Description and use
Rewrote the LINE Bot from Python to Go 1.26, reducing Cloud Run resource usage from 4 vCPU / 4 GiB to 1 vCPU / 1 GiB while maintaining all features and enabling zero‑downtime switching.
Problem
The Python implementation of the LINE Bot consumed 4 vCPU / 4 GiB on Cloud Run due to heavy memory usage from many AI and document‑processing packages.
Outcome
The Go rewrite reduced Cloud Run resource usage from 4 vCPU / 4 GiB to 1 vCPU / 1 GiB while preserving all features and enabling zero‑downtime switching.
Workflow
- 1. Created Go repository and mapped all Python features to Go packages.
- 2. Defined 11 GitHub issue milestones for each package and unit tests.
- 3. Implemented multi‑stage Dockerfile with Chromium, single‑file, and ffmpeg.
- 4. Built Gemini dual‑channel client supporting Vertex AI and Gemini API.
- 5. Re‑implemented Firestore persistence layer compatible with existing schemas.
- 6. Ported LINE Messaging API handling with HMAC verification and Flex carousel assembly.
- 7. Re‑implemented URL crawler and multi‑format document conversion.
- 8. Re‑implemented AI toolset for summaries, social copy, grounding, vision, etc.
- 9. Integrated ADK orchestrator with 5 specialized agents.
- 10. Added asynchronous webhook handling and postback dispatching.
- 11. Deployed to Cloud Run, stress‑tested, and reduced container resources.
- 12. Verified zero‑downtime switching by sharing Firestore data.
- 13. Monitored resource usage and confirmed reduced memory and CPU.
- 14. Documented architecture and future maintenance plan.
Evidence
the resident memory for Python + FastAPI + a large number of document parsing and AI packages kept increasing
deploy it to Cloud Run in the same GCP project, and ensure it shares Firestore data with the old version for zero-downtime switching at any time.
1 vCPU / 1 GiB
- Record date: 2026-11-03T14:28:54.875Z