阿姆达尔定律
并行化带来的加速受限于无法并行的工作比例。
显示原始英文内容
Amdahl's Law
The speedup from parallelization is limited by the fraction of work that cannot be parallelized.
Takeaways
- Sequential work sets the ceiling, and no amount of parallelism can overcome it.
- Scaling exposes bottlenecks. More resources make limits visible, not disappear.
- Fix before you scale: reduce sequential paths first. Parallelism comes second.
- It applies to people, too. Decision bottlenecks can dominate at the team scale.
Overview
As you add CPU cores, only the parallelizable fraction of your code speeds up. The sequential fraction remains unchanged and eventually dominates total execution time. If "s" is the sequential fraction, the maximum speedup with infinite parallel resources is 1/s. So if 10% is sequential, maximum speedup is 10x. If 50% is sequential, maximum speedup is only 2x.
This applies beyond hardware. If your system has a database that can't be parallelized, adding application servers hits a wall. The same holds for organizations: if one person or committee handles all architectural decisions, adding engineers increases coordination costs without increasing throughput.
Examples
Adding application servers doesn't help if all requests hit a single database instance. One database becomes the limit.
Another example: breaking a monolith into microservices won't improve performance if all requests ultimately serialize through a shared dependency, such as an authentication or billing service.
Origins
Gene Amdahl, a computer architect known for his work on IBM mainframes, introduced the law in 1967 at the AFIPS Spring Joint Computer Conference.
It was originally framed around processor performance but has since proven universally applicable to systems and organizations.
核心含义
如果一个任务中有一部分必须串行执行,那么增加处理器或服务实例只能加速其余部分。串行部分会成为最终上限,系统的理论加速比不会无限增长。
优化并行部分之前,应先确认串行瓶颈在哪里;增加资源不一定能解决排队、锁竞争或单点协调问题。
实践例子
一个数据处理流程中 20% 的时间用于串行准备,剩下 80% 可以并行。即使并行部分无限加速,整体也只能获得有限的提升。
来源与边界
Gene Amdahl 在讨论大型计算机系统时提出这一定律。它适用于固定问题规模;当问题规模随资源增加时,还应结合 Gustafson 定律分析。