Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Frank de Jonge:
Partitioning for concurrency in synchronous business processes.
Oct 02, 2017 @ 12:18:16

Frank de Jonge has a tutorial posted to his site showing you how to use partitioning for concurrency in optimizing the business logic processing in your PHP applications.

With new ways of dealing with problems, new problems emerge. When the solution space evolves, so do the problems we deal with. One could say we only exchange one type of problem with another.

[...] Such constraints might steer you towards a synchronous solution, but a deeper understanding of a given domain might allow for an alternative approach. The need for synchronous processing is not always as final as it may seem. Sequential handling may only be a requirement within a certain context. A context may be defined by anything related to a single user, group, or even a process.

He talks some about concurrent processing versus sequential processing and how, sometimes, pure versions of either aren't exactly the right fit. Instead he proposes a system where multiple streams could be used with synchronous handling keeping with the concurrency between the streams. He illustrates his point with a "silly chat application" with the requirement that users all get their emails in order. In his proposal he starts with a standard single thread/multiple workers scenario but points out that this may lead to messages being out of order depending on the processing time for the worker it ends up on. He refactors this into a system that uses the parallel processing instead, including the PHP code that's required to make it work.

tagged: partition concurrency parallel processing business tutorial split

Link: https://blog.frankdejonge.nl/parallelise-synchronous-business-processes/