In my work, we had a server migration to relocate all of our files to a newer server to handle our company’s increasing load. However, something unexpected happened. In testing our PHP codes to ensure integrity, we had encountered a very strange bug. In some pages, includes, classes and functions began to have 2 or 3 instances in a page instead of having just one.
In our effort to isolate the bug, we tried commenting codes, classes, and functions so we could pinpoint the source of the error. Mysteriously, after commenting several lines of code, the bug would suddenly dissappear, but would then reappear when the lines of PHP codes reached a critical mass (loops and recursions were the common culprit). Then it hit me. Could it be possible that PHP was creating a race condition?
Immediately, I checked the php.net documentation. I found out from the installation manual, that PHP is not compatible with Apache 2’s multi-threaded environment. Although the PHP core is thread-safe, its 3rd party libraries are not. According to PHP’s website, this problem can be remedied by using the pre-fork MPM instead of the threaded MPM, or you can also downgrade the apache back to version 1. Nevertheless, we reported our findings to the ITS department and our server went down again to recompile Apache.









