YouTube: https://www.youtube.com/watch?v=gtjzjiTI96c
At Netflix we run hundreds of A/B tests every year. Maintaining multivariate experiences quickly adds strain to any UI engineering team. In this talk, Alex Liu explores 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.
This is the condensed 20 minute version given at NodeConfEu 2014.
28. 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;
35. var packager = require('nf-packager'),
includeWhen = require('nf-include-when'),
registries = require('nf-asset-registry');
function getScriptUrl()
return packager.getPackageDefinition('app.js',
registries,
includeWhen);
}
36. "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.
37. [
"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.
38. [
"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.
✓
39. [
"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.
✓
40. Step 5:
Concatenate the files.
[
"jquery", /* no rule */
"newSearchDep2.js", /* no rule */
"newSearchDep1.js”, /* no rule */
"newSearch.js" /* rules.inNewSearch */
]