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 iOS using Swift:

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

As described previously, if many consecutive failures are received and interstitialDidFailToLoadAd method is frequently called, then MoPub SDK will trigger Rate Limiting, and immediately fail the requests. This will again cause interstitialDidFailToLoadAd 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:

- (void)interstitialDidFailToLoadAd:(MPInterstitialAdController *)interstitial {
    [self.interstitialAd loadAd];
}

This will most likely trigger Rate Limiting. You should not allow loadAd to be called immediately, but instead wait for some time. There are many ways to achieve this. As an example on iOS with a 10 second delay, you can utilize iOS’s Dispatch framework to call loadAd using dispatch_after method:

- (void)interstitialDidFailToLoadAd:(MPInterstitialAdController *)interstitial {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self.interstitialAd loadAd];
    });
}

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

Last updated February 11, 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.)