YsummarY, use Tab ↹, Return/Enter and go back (⌘ + ←) to navigate.

FastAPI vs Go (Golang) vs Node.js: Performance & Price

YouTube Video

This YouTube video benchmarks FastAPI (Python), Node.js, and Go’s performance when deployed on VMs using systemd, contrasting with previous Kubernetes-based tests. Key findings include:

Test 1 (Simple Static Test):

  • Methodology: Measured latency, throughput (requests per second), CPU & memory usage, and availability on an m7a.large instance (2 vCPUs, 8GB RAM). Node.js used cluster mode.
  • Results: Go and Node.js significantly outperformed Python. While Node.js initially showed better CPU efficiency, Go achieved higher throughput (nearly 85,000 RPS vs. Node.js’s ~80,000 RPS and Python’s ~12,000 RPS). Latency was very close between Go and Node.js, with Python exhibiting far higher latency. VMs showed better performance than the previous Kubernetes tests.

Test 2 (Realistic Test with Database and Cache):

  • Methodology: Added PostgreSQL and Memcached, measuring latency for the entire POST request (client-side and application-to-database/cache), CPU usage of all components, connection pool size, and memory usage. Each application’s connection pool was limited to 500.
  • Results: Go consistently outperformed Node.js and Python, showing better stability and handling of network requests. Node.js remained competitive, especially considering its full-stack capabilities. Python’s performance degraded significantly at around 3,500 RPS, while Go and Node.js reached around 15,000 RPS.

Cost Comparison:

  • Based on the $85/month cost of the m7a.large instance, running Python at the same throughput as Go would require approximately four times the number of instances, significantly increasing costs. This difference becomes more pronounced at scale.

Overall Conclusions:

  • For simple, static applications, Node.js and Go offer comparable performance, drastically outpacing Python.
  • In realistic scenarios involving databases and caches, Go shows a clear advantage in stability and throughput over Node.js and Python.
  • Node.js remains a strong contender, particularly for full-stack development where JavaScript is already used on the frontend.
  • Python’s performance limitations become especially problematic at scale, potentially making it costly to operate. Its suitability depends heavily on the scale of the application.
  • The video emphasizes the importance of measuring latency from the client perspective for accurate performance assessment.

The video provides source code and systemd files for reproducibility.

Next: Master BorgBackup 1.4.0: Init, Create, Prune, Remote SSH, and More!
Prev: Don't make this mistake when upgrading to 10Gbit network