I need advice on the best way to approach this. The site is loading pages in 30 seconds, sometimes 1 minute. This will kill my traffic if it's rolled live.
I ran an strace on one of the pages, which took 23 seconds to load completely, and ran an strace on it, which records every single system call made by the site during this loading time. There were no specific system calls taking more than than a few milliseconds excluding a call to the main Magento core bootstrap.php which is normal, and that in itself took 1.6 seconds from the total. The rest of the calls as mentioned take milliseconds each, but due to the amount of calls, 188979, the process just takes too long.
We have tried changing PHP version - it didn't work.
I tried several minor fixes like using a different PHP version, temporarily disabling opcache as there were a fair number of calls to files generated by it, but nothing much changes.