How to parallelize processes in PHP

Today we will explain how to fork a process in our PHP scripts, so, we can parallelize processes that have a big load for the processor or simply they can be launched in parallel since they do not have dependencies between them and all of them solve partially a common task.

Why do we need to parallelize processes?

When we develop and algorithm, depending on the language that we use to programm it, we can solve the parts of the algorithm sequentially or in parallel. If we have a section of the algorithm which has a big processing load and requires a long time for its resolution, we could solve other parts while the slowest part of the algorithm is being solved. So, the total running time of our algorithm goes from being the sum of the parts to only the slowest part. It is true that we can only take advantage from parallelization when we have redundant resources (e.g: processors), but most of the existing servers have multiple cores, so it has enough income to learn to parallelize our processes.