To control the display of different items on varying periodicity for a web applicatio
Smitha S Nair
Greenhorn
Joined: Apr 25, 2007
Posts: 1
posted
0
We need to implement a logic for a web application where in we need to control the display of some items with varying frequency/percent. For eg. let us say I need show an ad a specific percentage of users. There might be different products under different brands and I have to maintain a certain percentage for the combination of brand/product. I could define the percentage for each brand/product in an XML/properties file. The question is how to ensure the ads do stick to this.
One way would be to maintain an application wide session to track the user counts and maintain a brand/product combination ad hit to ensure a certain percentage/number.
But with a growing number of brand/product combination, the session object might get too huge to manage and also might affect the performance
We also tried to use random number and check agains a specified percentage and determine if the current session falls under this percentage (A sample program below). But there was a variation of about 10%.
Please suggest if you are aware of a better logic of achieving this, so that more accurately stick to the percentages.
This is the sample code we tried, please note that the count below is just an indicative one which would be replacing the actual code and hence cannot be used to tweak to stick to the percentage.
public class TestRandomTwo{ public static void main(String args[]) { int countA = 0; int percentA = 30; int countB = 0; int percentB = 100; int countC = 0; int percentC = 50;
Yup, random does not guarantees a perfect distribution. Delivering add x on exactly n% of page displays is impossible. After one sample it will be 0% or 100%. Oh my!
I have used a scheme with "weights" instead of percentages. You could buy more weight, but if your competitor buys the same amount the percentage might be 50%. I was trying to encourage weight building wars.
Can that work?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: To control the display of different items on varying periodicity for a web applicatio