If you are really concerned about performance, measure first if the PHP (or other) implementation is fast enough. You may find out that there is no need to worry. If these are really difficult calculations (and it is likely that they will increase as your application develops), it would be advisable to run the calculations asynchronously in a separate server service. For example, your PHP interface might send a C / C ++ service that ultimately puts the results in a database. This requires a lot of additional logic, someone (the client) will have to interrogate regularly, but it scales well.
There are other things to consider than performance: if your math is complex and continues to grow, PHP may not be a good medium for formulating it. Again, perhaps a Java stack with a clear separation of interfaces and business logic might be best in terms of service.
source share