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

  1. A hit on the webpage calls the Throttle calculation code automatically.
  2. 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:
      1. Calculate the amount of time elapsed from last call
      2. Using the current hit-count (for 60mins) and the minutes elapsed, calculate the number of hits we would have expected during this period
      3. Remove this expected amount from the total hitcount.
      4. Add 5 to the total hitcount.
        Remember: done 1/5 times, equates to 1 hit 1/1.
      5. Store timestamp & hitcount.

Notes

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.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: