• For some use cases, some or all of the following is True: • Drupal is slow • PHP doesn’t scale • PHP was never designed for this • Isomorphic code Why? mandag den 29. oktober 12
• Your server acting as it had absolute dementia • Works well for old school web pages • Not really good for modern web applications Shared nothing mandag den 29. oktober 12
• Websockets • Realtime • Streaming • etc. • PHP is 17 years old – semantically tied to HTTP anno MCMXCV. PHP was never designed for this mandag den 29. oktober 12
What? • Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. • Node.js uses an event-driven, non- blocking I/O model that makes it lightweight and efficient, perfect for data- intensive real-time applications that run across distributed devices. mandag den 29. oktober 12
• The ultimate DRY for web developers • Share business logic between client and server • No more having to implement validation twice Isomorphic code mandag den 29. oktober 12
Stateful server • Everything is so much easier (just stick it in an array) • Everything is so much harder (what’s going on here, who moved my cheese?) • No database roundtrips (fast) • No persistence (ouch) mandag den 29. oktober 12
1 var dnode = require('dnode'); 2 var net = require('net'); 3 4 var server = net.createServer(function (c) { 5 var d = dnode({ 6 transform : function (s, cb) { 7 cb(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase()) 8 } 9 }); 10 c.pipe(d).pipe(c); 11 }); 12 13 server.listen(5004); Node.js mandag den 29. oktober 12