Say I have 10 ads that are displayed on a website.
If ad #1 is to be displayed 100K in a given month, how would you go about evenly/smoothly display these ads throughout the day?
I have to take traffic spikes into consideration, so I can't simply divide 30 days by 100K or 3K impressions per day.
Is there a formula for this type of problem domain?
Well, for one thing you cannot know how many visits your site will get, so you cannot ensure that each ad will be shown exactly X times. For instance, if ad #1 is to be displayed 100K times, and ad #2 is to be displayed 200K times, but you get only 150K visits, then you cannoy possibly satisfy anything. And on the other hand, if you get 600K visits, then every other visit should have no ad. But you have no way to predict this in advance.
Hence, I'd advise the same thing as tskuzzy - pick ads on random, but adjust their probabilities so that they approach the right amount of views. And, of course, track how many times each ad has been shown, and remove it from the rotation once the limit has been reached.
Let's look at an example. Suppose you have two ads. Ad #1 still needs to be shown for 7 more days, and needs to get 70K more views. Ad #2 needs to be shown for 10 more days, and needs 20K more views. So, ad #1 should be shown on average 10K times each day, and ad #2 - 2K times each day. So the probability of ad #1 coming up should be 10/(10+2)=5/6, and the probability of ad #2 should be 2/(10+2)=1/6. Hence for every 12K views you will get on average 10K views of ad #1, and 2K views of ad #2. Which is what you need.
Recalculate these probabilities at the start of each day and only add new ads at the same time. If you add new ads in the middle of the day, it will complicate things. However it will work just as well if you calculate time in seconds, not in days, so you might do that too for a greater accuracy. Just keep an eye on performance if you recalculate everything so often.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With