My server is slow due to high CPU usage. I tracked the source of using a large number of processors for several reasons:
- a large number of regular expressions on datasets.
- strpos, operations substr.
- Loops through arrays for basic mathematical operations.
All of these operations are necessary for a single search on my website. If the visitor performs a search, the processor switches to 100%. I can do nothing with these operations because they are necessary.
My questions:
- What would be the best way to configure configuration files such as httpd.conf or php.ini, given that the above operations are the reason for almost all CPU usage?
- What would be the best way to upgrade the server, given that the above operations are the reason for almost all CPU usage?
UPDATE 1:
Operation example:
preg_match_all('/ValuesBreakdown_\d+_[A-Z]+_out.push\(([\d.,]+)/',$content,$matches);
This single operation does not use much CPU, but it is a large number of such operations that add up.
source
share