CH-J Toolsserver management over SSH
Menu
All guides and articles →

How to detect unnecessary CPU load caused by SHA-256 calculation

The case of repeated verification of a web publication: process identification, request memoization, profiling, and safe relocation of the full verification.

The right control may be running in the wrong place

SHA-256 is not a bug or a useless technology in itself. The problem arises when an application repeats the physical calculation on the same data much more often than the security model requires. Reading a large number of files on each regular request can consume a significant amount of CPU and I/O, even if the individual call looks innocent.

During the CH-J audit on November 28, 2026, we found that the verification of published languages was re-running the corresponding files and checksums. Static memoization only helped within one PHP request. The next request started again. OPcache had a different purpose and did not automatically remove this data work.

First, determine the really loaded process

A high reading for a website doesn't necessarily mean that the CPU is being consumed by an NGINX worker. It could be PHP-FPM, a publisher, compression, backup, or another service on the same VM. Monitor processes at the same time as the peak and differentiate the percentage of a single core from the total host. The dashboard name alone doesn't indicate the cause.

ps -eo pid,comm,pcpu,pmem --sort=-pcpu
# PID nahraďte konkrétním zjištěným procesem:
pidstat -p PID 1 5

The availability and format of the tools depend on the system. A short read sample is not a long-term proof and may miss a recurring task. If the load comes in waves, compare the time to requirements, publication, and scheduled checks. The matching process is a starting point for further profiling, not a ready-made explanation.

Distinguish CPU time and wait

User response time can include network, queue, disk, and backend. To hypothesize repeated hashing, you need to find out how much time a particular function takes and how often it is called. A suitable profiler or isolated instrumentation will help distinguish hash computation from metadata retrieval and parsing. A random slow GET alone will not prove this cause.

Profiling on production can have its own costs and capture sensitive information. Use a targeted, appropriate approach and, if possible, a representative isolated copy. Do not enable blanket, granular monitoring of all workers without time limits. The goal is to test a specific hypothesis with reasonable impact.

Documented before and after measurements

The controlled experiment CH-J ran on the same standalone 6vCPU VM, with the same data and 40 variant requests at a rate of 4 per second. The median CPU of the validation function dropped from 201.403 ms to 0.129 ms. For the real PHP homepage, the median CPU dropped from 205.732 to 6.247 ms.

This corresponds to approximately 99.94% CPU savings for this feature and 96.96% CPU savings for the measured homepage. This is not a new production measurement for each subsequent hit. Nor is it an automatic promise of the same savings on another site. The experiment isolated a specific change in the verification path, so its conclusion is narrower and at the same time well explainable.

Remove repetition, not required integrity

The solution is not to mindlessly delete all checksums. It is necessary to determine who is allowed to change the content and when full verification is required. For an immutable publication, full verification can occur at revision creation and activation, and during controlled subsequent auditing. HTTP then uses a protected result tied to a specific local revision.

Such a change requires consistent staging, verified inventory, appropriate permissions, and defined behavior in case of mismatch. If the same webroot remains writable without any publication binding, a simple long cache can hide erroneous changes. Also, the file size and mtime are not cryptographic proof of the same bytes.

Beware of fake repairs

Replacing SHA-256 with a weaker hash does not address the replay architecture and may change security features. Increasing the number of FPM workers will spread the same work across multiple processes. A longer timeout will allow for longer waits, but will not reduce the request. First, determine the number of calls, the volume of data, and the required frequency of checks.

The monitor can also be a source of traffic: frequent verification of multiple languages or endpoints can trigger an expensive journey regardless of human traffic. Separate light availability from full auditing. Periodic checking should have its own limits, visible result, and age. However, turning it off completely would remove another necessary layer of protection.

Repair verification

  • The same input and frequency have comparable instrumentation.
  • The CPU dropped in both the expected function and the relevant process.
  • New publication and broken data have correctly tested behavior.
  • Readiness does not report a healthy state when the result is invalid.
  • Production benefit is not confused with isolated fixture numbers.

Good optimization explains why the job repeatedly stopped running, while also showing where the necessary checks were left. It is this coupling that distinguishes safe acceleration from simply removing checks. For later CPU spikes, it is still necessary to figure out the current process and timing; an old finding does not automatically explain every new situation.

Frequently asked questions

Is SHA-256 itself unsuitable for the web?

No. The problem may be the number and location of repeated calculations.

Will OPcache help with every hash_file?

Not automatically. OPcache caches bytecode, not arbitrary results of data operations.

Does this case explain every CPU spike?

No. The new situation needs to be re-assigned to a specific process and work.

Detailed documentation

PHP: hash_file →

PHP: OPcache →

sysstat: pidstat →

Biometric unlock and security →

All tutorials by category →