Search⌘ K

Amdahl's Law

Explore the key concepts of Amdahl's Law and its limits on the maximum speedup achievable through parallelism in Ruby programs. Understand how serial portions of code affect concurrency and processor utilization as you increase threads or cores. This lesson prepares you to evaluate and optimize performance in multithreaded applications for senior engineering interviews.

We'll cover the following...

Amdahl’s Law

No text on concurrency is complete without mentioning Amdahl's Law. The law specifies the cap on the maximum speedup that can be achieved when parallelizing the execution of a program.

If you have a poultry farm where a hundred hens lay eggs each day, then no matter how many people you hire to process the laid eggs, you still need to wait an entire day for the 100 eggs to be laid. Increasing the number of workers on the farm can't shorten the time it takes for a hen to lay an egg. Similarly, software programs consist of parts that can't be sped up even if the number of processors is increased. These parts of the program must execute serially and aren't amenable to parallelism.

Amdahl's law describes the theoretical speedup a program can achieve at best by using additional computing resources. We'll skip the mathematical derivation and go straight to the simplified equation expressing Amdahl's law:


S(n)=\frac{1}{(1-P)+\frac{P}{n}}


  • S(n) is the speed-up achieved by using n cores or threads.

  • P is the fraction ...