Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Performance Comparison and Migration
性能比较与迁移

What you’ll learn: How to think honestly about JVM performance versus Rust native performance and when migration is actually justified.
本章将学习: 如何诚实地比较 JVM 性能和 Rust 原生性能,以及什么时候迁移才真的说得过去。

Difficulty: 🟡 Intermediate
难度: 🟡 中级

Rust often wins on startup time, memory footprint, and tail-latency predictability. Java often wins on mature libraries, team familiarity, and framework productivity.
Rust 通常在启动时间、内存占用和尾延迟可预测性上更强;Java 则常常在成熟库、团队熟练度和框架生产力上更占优。

Where Rust Usually Wins
Rust 通常更强的地方

  • startup time
    启动时间。
  • binary distribution simplicity
    二进制分发更简单。
  • memory footprint
    内存占用更小。
  • predictable latency under load
    负载下延迟更可预测。

Where Java Still Holds Up Well
Java 依然很能打的地方

  • large business systems with mature Spring-based workflows
    基于 Spring 的大型业务系统。
  • teams optimized for JVM tooling and operations
    已经围绕 JVM 工具和运维体系优化好的团队。
  • applications where throughput is fine and developer speed matters more than native efficiency
    吞吐已经够用,而开发速度比原生效率更重要的应用。

Migration Rule
迁移规则

Benchmark the actual workload before declaring victory. Replace hype with measurements:
先测真实负载,再谈胜利。别拿情绪和口号替代测量:

  • p50 and p99 latency
    p50 和 p99 延迟。
  • memory use
    内存占用。
  • startup time
    启动时间。
  • deployment complexity
    部署复杂度。

Rust is strongest when it solves a concrete operational pain, not when it is adopted as an aesthetic preference.
Rust 最强的时候,是它在解决一个明确的运行问题,而不是被当成审美选择时。