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 Unity using C#:

On the class you handle interstitial lifecycle events (that also registers to OnInterstitialFailedEvent), after you request an ad using MoPub.RequestInterstitialAd, it can result with a success and trigger OnInterstitialLoadedEvent callback, or it can result with a failure and trigger OnInterstitialFailedEvent callback.

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

After binding fail event to a local method:

MoPubManager.OnInterstitialFailedEvent += OnInterstitialFailedEvent;

Implementing the fail scenario such as:

private void OnInterstitialFailedEvent(string adUnitId, string error)
{
    MoPub.RequestInterstitialAd(adUnitId);
}

This will most likely trigger Rate Limiting. You should not allow MoPub.RequestInterstitialAd to be called immediately, but instead wait for some time. There are many ways to achieve this. As an example on Unity with a 10 second delay, you can utilize Unity’s Coroutine pattern:

void OnInterstitialFailedEvent(string adUnitId, string error)
{
    StartCoroutine(LoadInterstitialDelayed(adUnitId));
}

bool isRequestingInterstitialDelayed = false;

private float interstitialRequestDelay = 10.0f;

IEnumerator LoadInterstitialDelayed(string adUnitId)
{
    if (isRequestingInterstitialDelayed)
        yield break;

    isRequestingInterstitialDelayed = true;

    yield return new WaitForSeconds(interstitialRequestDelay);

    MoPub.RequestInterstitialAd(adUnitId);

    isRequestingInterstitialDelayed = false;
}

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.)