v0.18
Docker、Kubernetes 為什麼都用 Go 寫?兩個專案的原型分別是 Python 與 Java,公開前都改用 Go 重寫。這支影片先看 Solomon Hykes 與 Joe Beda 自己留下的說法,再看 Go 的設計和 goroutine、Java 的虛擬執行緒怎麼讓大量工作一起等,接著用同一個小 HTTP 服務比較啟動時間、記憶體和產物大小,最後看 AOT 快取與 Spring 的封裝各要付什麼代價。
看完,你能說出這兩個專案當年選 Go 的理由,也能依條件判斷 Go 與 Java 各適合什麼。
資料的條件:
- 原型的說法來自當事人本人:Solomon Hykes 2020 年的貼文、Joe Beda 2018 年的文章。選 Go 的理由來自 Hykes 2013 年的留言與簡報、Beda 2014 年的文章。Docker 的第一個原型是 Python,Kubernetes 的原型是 Java;公開的儲存庫從第一個 commit 就是 Go。原型的時間與規模沒有一級來源。
- 實測是本頻道在 2026-11-20 量的:Apple M4、32 GB 記憶體,Mac 上的 Docker(OrbStack),每個容器限制 2 CPU、1 GiB,每項取 5 次的中位數;Go 1.27.4、Java(Temurin)25.0.5(eclipse-temurin:25-jre 標籤 2026-11-17 起指 25.0.5.1,重跑結果可能略有差異)、Spring Boot 4.2.0。啟動時間從 docker start 算到第一個成功的 HTTP 回應。JVM 用預設設定,不加 -Xmx。錄影畫面的 Spring Boot 關掉 banner、log 只留訊息;實測數字用預設設定。第 6 章另跑一萬個各等一秒的任務,量從送出任務到全部結束的時間與記憶體峰值(VmHWM),同樣的容器限制與 5 次中位數。HTTP 服務只量啟動時間、記憶體(RSS)與產物大小;兩個測試都沒有量吞吐量與延遲,數字也不能和別人在 Linux 主機上量的直接比。
- 朋友與頻道主的經驗是個人的使用感受,不是統計。
Go is a trademark of Google LLC. Docker is a trademark of Docker, Inc. Kubernetes is a registered trademark of The Linux Foundation. Java, GraalVM, and Oracle are trademarks of Oracle and/or its affiliates. Spring and Spring Boot are trademarks of Broadcom Inc. and/or its subsidiaries. Python is a registered trademark of the Python Software Foundation. 本頻道與以上及影片中提到的公司、專案沒有贊助或合作關係。
配樂:ElevenLabs Music(AI 生成),依 ElevenLabs 商用授權使用。
章節
0:00 Go 與兩個原型
0:33 Docker 為何重寫
1:49 Kubernetes 的選擇
3:20 Go 的設計目標
4:18 goroutine 怎麼排程
5:39 Java 的虛擬執行緒
6:57 同一個服務實測
8:06 啟動時間
8:33 AOT 快取
9:41 Native Image
10:11 兩邊的代價
10:58 當年為何選 Go
參考資料
- X〈A bit of history. The first Docker prototype was in Python.〉(2020-02-06):https://x.com/solomonstre/status/1225250823610830848
- Hacker News〈Docker - Way better than a VM 討論串的留言〉(2013-05-19):https://news.ycombinator.com/item?id=5732413
- Jérôme Petazzoni〈From dotCloud to Docker〉(2017-02-24):https://jpetazzo.github.io/2017/02/24/from-dotcloud-to-docker/
- Docker〈What is Docker?〉(2026-09-07):https://web.archive.org/web/20261116001432/https://docs.docker.com/get-started/docker-overview/
- SlideShare〈Docker and Go: why did we decide to write Docker in Go?〉(2026-11-18 查閱):https://www.slideshare.net/slideshow/docker-and-go-why-did-we-decide-to-write-docker-in-go/28015076
- Gopher Academy Blog〈Kubernetes + Go = Crazy Delicious〉(2014-11-11):https://blog.gopheracademy.com/birthday-bash-2014/kubernetes-go-crazy-delicious/
- Go〈Frequently Asked Questions (FAQ)〉(2026-11-18 查閱):https://go.dev/doc/faq
- Go〈Go at Google: Language Design in the Service of Software Engineering〉(2012-10-25):https://go.dev/talks/2012/splash.article
- Go〈Release History〉(2026-11-18 查閱):https://go.dev/doc/devel/release
- Go〈runtime package〉(2026-11-18 查閱):https://pkg.go.dev/runtime
- OpenJDK〈JEP 444: Virtual Threads〉(2026-11-18 查閱):https://openjdk.org/jeps/444
- OpenJDK〈JDK 21〉(2026-11-18 查閱):https://openjdk.org/projects/jdk/21/
- OpenJDK〈JDK〉(2026-11-18 查閱):https://openjdk.org/projects/jdk/
- Spring〈Spring Boot 4.2.0 available now〉(2026-11-19):https://spring.io/blog/2026/11/19/spring-boot-4-2-0-available-now
- OpenJDK〈JEP 483: Ahead-of-Time Class Loading & Linking〉(2026-11-18 查閱):https://openjdk.org/jeps/483
- OpenJDK〈JEP 514: Ahead-of-Time Command-Line Ergonomics〉(2026-11-18 查閱):https://openjdk.org/jeps/514
- Go Blog〈[ On | No ] syntactic support for error handling〉(2025-06-03):https://go.dev/blog/error-syntax
完整參考資料(27 筆):https://github.com/Stay-Junior-Studio/sj-studio-sources/blob/main/v0-19.md
相關影片
- v0.14 Spring 為什麼是 Java 框架第一選擇?:https://youtu.be/sa2_NEFM9BQ
- v0.17 Spring AI 讓 Java 工程師也能做 AI 產品:https://youtu.be/eYG3g2V_BoE
- v0.5 AI agent 時代,還要學程式語言嗎?又該學哪個呢?:https://youtu.be/NbNrghXEuHY
SJ Studio|Stay Junior
#Go #Docker #Kubernetes
Docker 用 Python、Kubernetes 用 Java,這兩個原型後來都被砍掉重寫成 Go,我第一反應是:換語言哪有這麼簡單,舊程式碼不就全部重來?但 Nick 把 Hykes 和 Beda 當年留下的說法翻出來,理由其實很具體,不是「Go 比較潮」這種等級。後面還真的用同一個查訂單小服務,把 Go、純 Java、Spring Boot 三份各跑一次,量啟動時間、記憶體和產物大小。