Throttle provides complete APIs for plugin developers which means you should not need to dig around in the innards too excessively. However, for those that want to understand how Throttle calculates and where it comes up with the 0-10 load value you see, a more detailed step-through is given below.
Step by Step
- A hit on the webpage calls the Throttle calculation code automatically.
- Only 1/5 (default) hits actually results in a recalculation to save host load.
- If the hit is not counted the function exits quietly.
- If the hit is counted it triggers the calculation process as follows:
- Calculate the amount of time elapsed from last call
- Using the current hit-count (for 60mins) and the minutes elapsed, calculate the number of hits we would have expected during this period
- Remove this expected amount from the total hitcount.
- Add 5 to the total hitcount.
Remember: done 1/5 times, equates to 1 hit 1/1.
- Store timestamp & hitcount.
The method of calculating current load is accurate, although it tends to lag slightly behind the actual load being experienced. This is dependent on the resolution (default:5) the Throttle is configured with. Lower resolutions improve accuracy but affect performance.