This is the extended (full) version of the talk given at HTML5DevConf 2014. A condensed version of this talk was previously given at NodeConfEU 2014.
At Netflix we run hundreds of A/B tests every year. Maintaining multivariate experiences quickly adds strain to any UI engineering team. Join us to explore the patterns we’ve built in Node.js to tame this beast - ultimately enabling quick feature development and rapid test iteration on our service used by over 50 million people around the world.
Video from NodeConfEU:
https://www.youtube.com/watch?v=gtjzjiTI96c
31. anatomy of a rule
var Rule = require('nf-rule-infrastructure'),
PaymentTest;
PaymentTest = new Rule('PaymentTest', function(context, params, cb) {
var test = context.abtests.get(10);
cb(test && test.cell(params.id));
});
module.exports = PaymentTest;
58. anatomy of a rule
var Rule = require('nf-rule-infrastructure'),
inNewSearch;
inNewSearch = new Rule('inNewSearch', function(context, cb) {
var test = context.abtests.get(1534);
cb(test && test.cell(1));
});
module.exports = inNewSearch;
65. var packager = require('nf-packager'),
includeWhen = require('nf-include-when'),
registries = require('nf-asset-registry');
function getScriptUrl()
return packager.getPackageDefinition('app.js',
registries,
includeWhen);
}
66. "app.js": {
"deps": [
"jquery",
"oldSearch.js",
"newSearch.js",
],
"depsFull": [
"jquery",
"oldSearchDep2.js",
"oldSearchDep1.js",
"oldSearch.js",
"newSearchDep2.js",
"newSearchDep1.js",
"newSearch.js"
],
"fileSize": "4.41 kB",
"fileSizeFull": "120.52 kB"
}
Step 1:
Get the full dependency tree for the
requested package from the registry.
67. [
"jquery", /* no rule */
"oldSearchDep2.js", /* no rule */
"oldSearchDep1.js", /* no rule */
"oldSearch.js", /* rules.notInNewSearch */
"newSearchDep2.js", /* no rule */
"newSearchDep1.js”, /* no rule */
"newSearch.js" /* rules.inNewSearch */
]
Step 2:
Determine which files have rules.
68. [
"jquery", /* no rule */
"oldSearchDep2.js", /* no rule */
"oldSearchDep1.js", /* no rule */
"oldSearch.js", /* rules.notInNewSearch */
"newSearchDep2.js", /* no rule */
"newSearchDep1.js”, /* no rule */
"newSearch.js" /* rules.inNewSearch */
]
Step 3:
Run the rules. Filter out all deps that
resolved false.
✓
69. [
"jquery", /* no rule */
"oldSearchDep2.js", /* no rule */
"oldSearchDep1.js", /* no rule */
"oldSearch.js", /* rules.notInNewSearch */
"newSearchDep2.js", /* no rule */
"newSearchDep1.js”, /* no rule */
"newSearch.js" /* rules.inNewSearch */
]
Step 4:
Filter out all extraneous
sub deps.
✓
70. Step 5:
Concatenate the files.
[
"jquery", /* no rule */
"newSearchDep2.js", /* no rule */
"newSearchDep1.js”, /* no rule */
"newSearch.js" /* rules.inNewSearch */
]