Rate Limiting

Explanation

The MoPub SDK imposes minimum wait times in between subsequent requests. If there are frequent ad requests that result in no fill, MoPub will Rate Limit the amount of outgoing requests. When this happens, the MoPub SDK will immediately fail the subsequent requests and notify publishers via ad failure callbacks.

To prevent MoPub Rate Limiting your request, you can optimize your ad requests and add a minimum wait time of 10 seconds in between unfilled ad requests.

Example

Here’s an example for imposing wait times on re-requesting Interstitials on Android using Java:

On the class or fragment you handle interstitial lifecycle events (that implements InterstitialAdListener), after you request an ad using load() method on your MoPub Interstitial View, it can result with a success and trigger onInterstitialLoaded callback, or it can result with a failure and trigger onInterstitialFailed callback.

As described previously, if many consecutive failures are received and onInterstitialFailed method is frequently called, then MoPub SDK will trigger Rate Limiting, and immediately fail the requests. This will again cause onInterstitialFailed to be called and can create a loop of failing requests.

This will likely happen if you are immediately re-requesting an ad on fail callback, like so:

@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
    // Ad load failed. Should re-request.
    moPubInterstitialView.load();
}

This will most likely trigger Rate Limiting. You should not allow load() to be called immediately, but instead wait for some time. There are many ways to achieve this. As an example on Android with a 10 second delay, you can utilize Java’s Handler class to call load() using postDelayed method:

@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
    // Ad load failed. Should re-request after 10 seconds.
    final Handler handler = new Handler();
    public static final int TEN_SECONDS_MILLIS = 10 * 1000;

    handler.postDelayed(new Runnable() {
      @Override
      public void run() {
        moPubInterstitialView.load();
      }
    }, delay);
}

This will re-request an interstitial ad 10 seconds later and will prevent Rate Limiting to be triggered.

Last updated March 04, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)