i know it was mean, but i cut the cord to lamp anyway
TRANSCRIPT
Planning Development Deployment
Actually do it Managing the flexibility What are my options?
Do I need a framework? The Basics The Upgrade
Dealing with SEO Simplifying Client Code Server Options
Finding the Right Talent Promise vs. Callback Choosing a Cloud
Planning - Failing to Plan
Pros ConsEasy Install Not good for inter object relationships
Flexible
Quick Development
Development - Flexible Base Service
+ save+ delete+ load
Widget Service
+ save+ delete+ load
Widget Service
+ save
Sprocket Service
+ save
{ object_type: “widget”, name: “”, description: “”}:
Development - Too Flexible?
Document with Strings{ object_type: “event”, type: “startup”, location: { lat: “35.7806”, lon: “78.6389” }}
Document with Floats{ object_type: “event”, type: “startup”, location: { lat: 35.7806, lon: 78.6389 }}
● Valid JSON● Pases non-strict validation (JS)● Geospatial index fails on insert
Development - Common Data Fields
{ “first_name”: “Charlie”, “last_name”: “Daniels”, ...
“doc_type”: “user”, “doc_version”: 1, “created”: “2014-09-11 15:01:07.602Z”, “last_modified”: “2014-09-11 15:01:07.602Z”, “created_by”: "5411b9334572668410000fd0”, “last_modified_by”: "5411b9334572668410000fd0”}
Development - Geospatial Indexing
The $geoWithin operator does not return sorted results. As a result MongoDB can return $geoWithin queries more quickly than geospatial $near or $nearSphere queries, which sort results.
db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } );
db.places.find( { "loc": { "$geoWithin": { "$center": [[50, 50, 5] } } });
==
Deployment - Expense at Scale
Deployment Cost Managed
AWS m1.large $0.20/hr NO
Compose.io $18/GB* YES
Mongo Lab $15/GB* YES
Linode Medium $20/mo NO
* Other base fees may apply
Planning - Do I need a framework?
● IS IT OPEN SOURCE?● How often will I need to upgrade?● If the project goes stagnant does that affect me?● If the project gets bought by a company I don’t like does that affect me?● What kind of custom functionality do I need to inject?● Will packages be sufficient or will I need to fork so I can experiment?● Do I want to maintain something custom?● Can I do as well as or better than what is already out there?
Development - The Basic Example
var express = require('express')var app = express()
app.get('/', function (req, res) { res.send('Hello World!')})
var server = app.listen(3000, function () {
var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port)})
Planning - Crawlers and Javascript
Pros Cons
Server Rendered Landing Pages
SEO becomes easier because it is the traditional model.
Even mediocre crawlers can navigate your site
Mix and match of SPA and traditional model
Tracking which pages need to be rendered server-side
Single Page App Consistent SEO implementation
Metadata data changes based on page context
Google is only search engine boasting javascript execution.
Development - A Simple Example
<ol> <li ng-repeat="user in users" ng-bind="user"></li></ol>
//service codeangular.module('myservices', []).service('simpleService', function(){ this.getUsers = function() { return ['John', 'James', 'Jake']; }});
//controller codeangular.module('myapp', ['myservices']).controller('SimpleController', function($scope, simpleService) { $scope.users = simpleService.getUsers();});
Development - A Growing Stack
Data Access
Service Layer and Business Logic
API Controller
Angular Service
Angular ControllerClient
Server
Separation of Concern => Testability
describe("Unit Testing Examples", function() {
beforeEach(angular.mock.module('App'));
it('should have a LoginCtrl controller', function() { expect(App.LoginCtrl).toBeDefined(); });
it('should have a working LoginService service', inject(['LoginService', function(LoginService) { expect(LoginService.isValidEmail).not.to.equal(null); }]) );});
Deployment - Serving a Single Page App?
Considerations:
● How much data do I need to persist?● Is my application solely a SPA?
Possible Options:
● Apache / PHP● Python● Rails● Node.js
Planning - Resource Management
Now that I use the same language across the entire stack hiring just got simpler.
Planning - Adoption
Big names are jumping on board:
● Linkedin● Walmart Labs● PencilBlue
http://nodejs.org/industry/
Development - Clustering
if (cluster.isMaster) System.onMasterRunning();else onChildRunning();
System.onMasterRunning = function() { //spawn workers var workerCnt = os.cpus().length; for (var i = 0; i < workerCnt; i++) { cluster.fork(); } cluster.on('disconnect', System.onWorkerDisconntect);
pb.log.info('System[%s]: %d workers spawned. Listening for disconnects.', System.getWorkerId(), workerCnt);};
Core 1 Core 2 Core 3 Core 4 Core 5 Core 6 Core 7
MW W W W W W W
Deployment - Shooting for the Cloud
Elastic Beanstalk OpenShift Nodejitsu Bluemix
Linode HerokuAzure
Deployment - Starting Simple
LB
M
W
M
W
W
W
Use SSL Termination
Pay for the backup service
Write a procedure for creating these nodes
Pros Cons
Extremely FlexibleRapid Development
Expensive at Scale
Fast “Good Enough” HTTP Server Upgrades cause code changes
A battle tank that can do anythingTestable
Overhead for smaller projects
Fast and efficient Hard to debug
To Recap...