I know that many of the solutions that I mention here are "ugly", but you sound like a person who wants to get results and refactoring, so I hope that everything is in order.
Do it in a simple way (PHP, if I understood correctly). Then do a realistic stress test. Since you are creating PHP calls, just create a realistic sequence (log in, change it, do it, log out) and run as many as you think are realistic. 100? 10000? It depends on how much you expect this thing to be and is still being reformed.
This step is easier than it sounds. Do not think that the "ultimate test environment", think that 20 lines of python script start as many threads as you want to execute several lines that will support your application. If you need more than 40 minutes, stop and simplify. The hour you spend will be worth it.
If the processor reaches 100 or you are running out of resources, it may be time to rewrite, or you might guess what to take the longest and write it to C. If you use C / C ++ and you are not 100% comfort with it, avoid major rewriting, as it is a dangerous language with many possibilities for introducing errors. Perhaps even call the compiled code from PHP that you have if it suits your application .
I wrote server-side C code with server-side code once. This is not the right tool for the job. PHP may be hacky, but it does its job quickly. I would avoid optimization if / until it is needed.
Good luck, do not forget to tell us how this happens!
Edit: If you are going to use a mixed language solution, be sure to clear it after! Standardize what you do quickly and what you do in PHP, do it in a common format, maybe write a short readme. Again, these fifteen minutes will save you, or the next person, a few days and a lot of hair.