Quick Answer: Amdahl's Law dictates that the maximum speedup of a parallelized program is strictly limited by the portion of its code that must run serially. If one-third of your application relies on sequential operations like resource locking, your maximum possible speedup is exactly 3x—regardless of whether you use 8 or 64 CPU cores.
You're really excited. You just dropped serious cash on a shiny new 8-core CPU. You compile your heavy workload, spin it up, and eagerly watch the execution time drop. But wait—it's only running three times faster than it did on your old single-core setup.
Assuming it’s a hardware bottleneck, you empty your wallet for a massive 64-core beast. I often see developers make this assumption: more cores means more speed, right? Yet when you run the program again, you're even more disappointed to find it still caps out at exactly three times faster.
What is happening here? You’ve just run headfirst into Amdahl's Law.
What is Amdahl's Law in software engineering?
Amdahl's Law is a principle that calculates the theoretical maximum performance improvement of a system when only a part of that system is optimized. When I explain this concept to other engineers, I emphasize that it proves the speed of a parallelized program is ultimately capped by the percentage of its code that must execute sequentially.
If a third of your program is serial code, the absolute maximum speedup you can achieve is three times. It mathematically defines the ceiling on how fast a program can run based entirely on the proportion of code that simply cannot be parallelized.
Why does serial code limit parallel processing speed?
Serial code creates a hard mathematical ceiling because certain operations must happen one after another to maintain data integrity. When parallel threads hit a shared resource and have to wait in line, adding more CPU cores yields zero additional speed because those extra cores are just sitting idle in the queue.
Programs inevitably have some amount of their makeup that is inherently serial. If you have shared state in your application, running multiple parallel processes against it without guardrails will corrupt your data. To prevent this, we introduce locks on shared resources.
Imagine your team is building a ticketing system for a massive stadium tour. Thousands of users can browse seats in parallel, but the actual checkout process requires a strict lock to ensure two people don't buy the exact same front-row seat. That checkout lock is serial. There is always some amount of your program that simply cannot be run in parallel, and that puts a permanent ceiling on how much throwing more hardware at the problem actually helps.
How does the serial proportion impact maximum speedup?
The theoretical speed limit of your application is inversely proportional to the fraction of its serial execution time. As you add an infinite number of cores, the parallel execution time approaches zero, leaving only the serial execution bottleneck.
I put together this quick breakdown to show how that mathematical ceiling plays out based on the serial makeup of your code:
| Proportion of Serial Code | Maximum Theoretical Speedup (Infinite Cores) |
|---|---|
| 1/2 (50%) | 2x |
| 1/3 (33.3%) | 3x |
| 1/4 (25%) | 4x |
| 1/10 (10%) | 10x |
| 1/20 (5%) | 20x |
This demonstrates why the concept of "more cores is more fast" is ultimately a lie. You cannot just throw more cores at a system forever. To actually make your application faster once you hit this hardware ceiling, you have to do the hard engineering work of refactoring your architecture to reduce shared state, minimize lock contention, and shrink that serial footprint.
Frequently Asked Questions
How is Amdahl's Law different from Moore's Law?
Moore's Law is an observation about hardware scaling over time, stating that the number of transistors on a microchip doubles roughly every two years. Amdahl's Law is a mathematical formula regarding software execution, defining the strict limits of parallelizing a specific workload regardless of how powerful the hardware is.
Does Amdahl's Law apply to distributed microservices?
Yes. In distributed systems, network latency, synchronized database writes, and single-threaded message queues act as the serial bottlenecks. Even if you spin up hundreds of container replicas, the system can only process requests as fast as the slowest sequential dependency allows.
What is Gustafson's Law?
Gustafson's Law is the counter-argument to Amdahl's Law. It suggests that as developers get access to more computing power, they don't just run the exact same problems faster; they increase the size and complexity of the problem. As the problem size grows, the parallel portion of the workload usually scales up while the serial portion remains relatively fixed, improving the overall efficiency of adding more cores.
Top comments (0)