i know it was mean, but i cut the cord to lamp anyway
TRANSCRIPT
I Know it was MEAN
but I Cut the Cord to LAMP Anyway
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
Follow along at:
pencilblue.org/presentation
MongoDB
Planning - Failing to Plan
Pros Cons
Easy Install Not good for inter object relationships
Flexible
Quick Development
Development - Prototyping vs. Production
Development - FlexibleBase Service
+ save
+ delete
+ loadWidget Service
+ save
+ delete
+ loadWidget 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 - Schema Documentation
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
Mongo HQ $18/GB* YES
Mongo Lab $15/GB* YES
Linode Medium $20/mo NO
* Other base fees may apply
Deployment - MMS & Getting to Scale
Routing & Frameworks
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?
Planning - Rube Goldberg of Software
Planning - The Forum Conundrum
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)
})
Deployment - Upgrading
What happens when I try to upgrade?
Chance of
Conflict
Time
Angular
Planning - Google did it!
Planning - Weighing In
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 code
angular.module('myservices', [])
.service('simpleService', function(){
this.getUsers = function() { return ['John', 'James', 'Jake']; }
});
//controller code
angular.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
Node.js
Planning - Resource Management
Now that I use the same language across the entire stack hiring just got simpler.
Planning - Resource Management
Planning - Adoption
Big names are jumping on board:
● Walmart Labs
● PencilBlue
http://nodejs.org/industry/
Development - Node Inspector
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
M
W W W W W W W
Deployment - Shooting for the Cloud
Elastic Beanstalk OpenShift Nodejitsu Bluemix
Linode Heroku
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 Flexible
Rapid Development
Expensive at Scale
Fast “Good Enough” HTTP Server Upgrades cause code changes
A battle tank that can do anything
Testable
Overhead for smaller projects
Fast and efficient Hard to debug
To Recap...
The choice is yours but...