Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pbs multiple servers #5209

Closed
wants to merge 90 commits into from

Conversation

idettman
Copy link
Contributor

@idettman idettman commented May 8, 2020

Type of change

  • Feature

Description of change

There are a couple of use cases for PBJS connecting to different Prebid Servers:

Programmatic Guaranteed

Comparison of Prebid Server host vendors

Multiple Prebid Servers can be specified, but no overlap in bidders. i.e. bidderZ always goes to one or the other

Requirements

  1. It must be possible to specify more than one Prebid Server in the s2sConfig setting
  2. If a bidder appears in multiple s2sConfig entries, log a console warning and logically remove that bidder from subsequent entries.
  3. If the s2sTest module is enabled:
    a) s2sConfig-defined test parameters should be interpreted the same: use a random number to decide whether the bidder should be contacted via the client-path or the server-path.
    b) AdUnit-defined test parameters are also interpreted the same: use a random number to decide whether the bidder should be contacted via the client-path or the server-path.
    Proposed Configuration and Expected Results for Phase 1
    The core idea here is to let s2sConfig optionally be an array. It could still support an object, which is interpreted as an array with a single entry.

Scenario 1: Running Programmatic Guaranteed as a separate bidder on a different PBS instance:

pbjs.setConfig(
  s2sConfig: [{
     bidders: [ "pgRubicon" ],   // a bidder alias is used here to obtain PG deals
     defaultVendor: "rubicon"
     },{
     bidders: [ "rubicon", "appnexus" ],
     defaultVendor: "appnexus",
     testing: true,
     bidderControl: {
         "rubicon": {
             bidSource: {server:10, client:90},
             includeSourceKvp: true
         },
         "appnexus": {
             bidSource: {server: 25, client:75},
             includeSourceKvp: true
         }
     }]
});

Scenario 2: Same bidder appears in multiple s2sConfig entries. This is basically an error condition for this phase.

pbjs.setConfig(
  s2sConfig: [{
     bidders: [ "bidderA" ],   // always use rubicon's PBS for bidderA
     defaultVendor: "rubicon"
     },{
     bidders: [ "bidderA", "bidderB" ],  // bidderA is ignored here. Use appnexus' PBS for bidderB
     defaultVendor: "appnexus"
     }]
});

nakamoto and others added 30 commits February 16, 2019 21:30
# Conflicts:
#	modules/advangelistsBidAdapter.js
#	test/spec/modules/advangelistsBidAdapter_spec.js
@idettman idettman removed their assignment Jul 23, 2020
Copy link
Collaborator

@robertrmartinez robertrmartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there may be some issues.

Using the following s2sConfig:

                s2sConfig: [
                    {
                        enabled: true,
                        bidders: ["appnexus"],
                        defaultVendor: "appnexus",
                        accountId: 1001
                    },
                    {
                        enabled: true,
                        bidders: ["rubicon"],
                        defaultVendor: "rubicon",
                        accountId: 1001
                    }
                ],

is not generating the expected output.

I would expect two prebidServer calls to happen:

One to Rubicon's PBS with the Rubicon bids
One to Appnexus's PBS with the Appnexus bids.

Below is the screenshot where you can see way too many requests are being fired:

image

As you can see we are seeing:
2 PBS requests to Appnexus
3 PBS requests to Rubicon
and a single Client side request to both Rubicon and Appnexus.

Let me know if you need any more information!

I will include the HTML page I was using below.

@robertrmartinez
Copy link
Collaborator

<html>

<head>
    <meta charset="UTF8">
    <script type="text/javascript" src="https://www.googletagservices.com/tag/js/gpt.js"></script>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script>
        /*
            Setup our GPT tag and slots
        */
        var googletag = googletag || {};
        googletag.cmd = googletag.cmd || [];

        googletag.cmd.push(function () {
            googletag.pubads().enableSingleRequest();
            googletag.pubads().enableAsyncRendering();
            googletag.pubads().disableInitialLoad();
            googletag.enableServices();
        });
        googletag.cmd.push(function () {
            googletag.defineSlot('/112115922/HB_QA_Tests', [[728, 90], [300, 250], [300, 600]], 'test_div_1').addService(googletag.pubads());
            googletag.defineSlot('/112115922/HB_QA_Tests', [[640, 480]], 'test_div_2').addService(googletag.pubads());
            googletag.pubads().enableSingleRequest();
            googletag.enableServices();
        });

        function sendAdserverRequest() {
            if (pbjs.adserverRequestSent) return;
            pbjs.adserverRequestSent = true;
            googletag.cmd.push(function () {
                pbjs.que.push(function () {
                    pbjs.setTargetingForGPTAsync();
                    googletag.pubads().refresh();
                });
            });
        }


        var adUnits = [
            {
                code: 'test_div_1',
                mediaTypes: {
                    banner: {
                        sizes: [[728, 90], [300, 250], [300, 600], [320, 250]]
                    },
                },
                bids: [
                    {
                        bidder: 'rubicon',
                        params: {
                            accountId: "1001",
                            siteId: "113932",
                            zoneId: "535510"
                        }
                    }, {
                        bidder: 'appnexus',
                        params: {
                            placementId: 13144370
                        }
                    }
                ]
            },
            {
                code: 'test_div_2',
                mediaTypes: {
                    "video": {
                        "context": "instream",
                        "mimes": [
                            "video/mp4",
                            "video/x-flv"
                        ],
                        "api": [
                            2
                        ],
                        "playerSize": [
                            640,
                            480
                        ],
                        "maxduration": 30,
                        "playbackmethod": [
                            2
                        ],
                        "linearity": 1,
                        "protocols": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6
                        ]
                    }

                },
                bids: [
                    {
                        bidder: 'rubicon',
                        params: {
                            accountId: "7780",
                            siteId: "87184",
                            zoneId: "412394",
                            video: {}
                        }
                    }, {
                        bidder: "appnexus",
                        params: {
                            placementId: 13232385,
                            video: {
                                skippable: true,
                                playback_method: ['auto_play_sound_off']
                            }
                        }
                    }
                ]
            }
        ];

        var pbjs = pbjs || {};
        pbjs.que = pbjs.que || [];

        // These are used so we can easily access the bid objects in our automation framework if needed
        my_bid_responses = [];
        my_bid_requests = [];

        function prebid_bid_requested(bid) {
            my_bid_requests.push(bid);
        };

        function prebid_bid_response(bid) {
            my_bid_responses.push(bid);
        };


        pbjs.que.push(function () {

            pbjs.enableAnalytics({
                provider: 'rubicon',
                options: {
                    accountId: 1001,
                    endpoint: 'http://prebid-a-q.us-west-1.elasticbeanstalk.com/event'
                }
            });

            // These events are triggered and add the bids to our custom arrays which we can open during automation in order to do validations!
            pbjs.onEvent('bidRequested', prebid_bid_requested);
            pbjs.onEvent('bidResponse', prebid_bid_response);

            pbjs.setConfig({
                bidderTimeout: 3000,
                s2sConfig: [
                    {
                        enabled: true,
                        bidders: ["appnexus"],
                        defaultVendor: "appnexus",
                        accountId: 1001
                    },
                    {
                        enabled: true,
                        bidders: ["rubicon"],
                        defaultVendor: "rubicon",
                        accountId: 1001
                    }
                ],
            });

            pbjs.addAdUnits(adUnits);
            pbjs.requestBids({
                bidsBackHandler: function (bidResponses) {
                    sendAdserverRequest(bidResponses);
                },
            });
        });

        setTimeout(function () {
            sendAdserverRequest();
        }, 10000);

    </script>
    <script async src="http://localhost:9999/build/dev/prebid.js"></script>

</head>

<body>
    <br><br>
    <h3>START test_div_1 Ad Slot</h3>
    <div id='test_div_1' style="position: relative; top: 1;">
        <script>
            googletag.cmd.push(function () {
                googletag.display('test_div_1');
            });
        </script>
    </div>
    <h3>END test_div_1 Ad Slot</h3>
    <br><br>
    <h3>START test_div_2 Ad Slot</h3>
    <div id='test_div_2' style="position: relative; top: 1;">
        <script>
            googletag.cmd.push(function () {
                googletag.display('test_div_2');
            });
        </script>
    </div>
    <h3>END test_div_2 Ad Slot</h3>
</body>

</html>

@ghost
Copy link

ghost commented Aug 6, 2020

Testing this out and believe adapterManager.aliasBidAdapter needs to be updated to add aliased bidders to the registry from the different configs. Something like the below:

adapterManager.aliasBidAdapter = function (bidderCode, alias, options) {
  let existingAlias = _bidderRegistry[alias];

  if (typeof existingAlias === 'undefined') {
    let bidAdaptor = _bidderRegistry[bidderCode];
    if (typeof bidAdaptor === 'undefined') {
      // check if alias is part of s2sConfig and allow them to register if so (as base bidder may be s2s-only)
      (_s2sConfigs || []).forEach(function (s2sConfig) {
        const s2sBidders = s2sConfig && s2sConfig.bidders;
        if (!(s2sConfig && includes(s2sBidders, alias))) {
          utils.logError('bidderCode "' + bidderCode + '" is not an existing bidder.', 'adapterManager.aliasBidAdapter');
        } else {
          _aliasRegistry[alias] = bidderCode;
        }
      });

@idettman idettman requested review from a user and jaiminpanchal27 August 19, 2020 17:02
@robertrmartinez
Copy link
Collaborator

@idettman @r-schweitzer

Is there any update on here?

Was under the impression a PR into this branch was pending and needed to be merged until it was ready to be re-reviewed?

Want to know when I can review again and test it out.

@ghost
Copy link

ghost commented Sep 1, 2020

Hey @robertrmartinez, we are still testing on our side. We needed to make a couple of adjustments already and I'm in the process of adding new unit tests and we're continuing to test on our side. I've also been on vacation and now sick. I will let you know when we're ready to push our code.

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 20, 2020
@stale stale bot closed this Oct 4, 2020
@bretg bretg reopened this Oct 7, 2020
@stale stale bot removed the stale label Oct 7, 2020
@stale
Copy link

stale bot commented Oct 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 22, 2020
@bretg bretg removed the stale label Oct 22, 2020
@ghost ghost mentioned this pull request Nov 17, 2020
@bretg
Copy link
Collaborator

bretg commented Nov 17, 2020

Obsoleted by #5992

@bretg bretg closed this Nov 17, 2020
@robertrmartinez robertrmartinez deleted the pbs-multiple-servers branch July 5, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review needs 2nd review Core module updates require two approvals from the core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prebid Server Bid Adapter: support multiple Prebid Servers
5 participants