i know it was mean, but i cut the cord to lamp anyway
TRANSCRIPT
![Page 1: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/1.jpg)
I Know it was MEAN
but I Cut the Cord to LAMP Anyway
![Page 3: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/3.jpg)
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
![Page 4: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/4.jpg)
Follow along at:
pencilblue.org/presentation
![Page 5: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/5.jpg)
MongoDB
![Page 6: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/6.jpg)
Planning - Failing to Plan
Pros Cons
Easy Install Not good for inter object relationships
Flexible
Quick Development
![Page 7: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/7.jpg)
Development - Prototyping vs. Production
![Page 8: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/8.jpg)
Development - FlexibleBase Service
+ save
+ delete
+ loadWidget Service
+ save
+ delete
+ loadWidget Service
+ save
Sprocket Service
+ save
{
object_type: “widget”,
name: “”,
description: “”
}:
![Page 9: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/9.jpg)
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
![Page 10: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/10.jpg)
Development - Schema Documentation
![Page 11: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/11.jpg)
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”
}
![Page 12: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/12.jpg)
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]
}
}
}
);
==
![Page 13: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/13.jpg)
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
![Page 14: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/14.jpg)
Deployment - MMS & Getting to Scale
![Page 15: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/15.jpg)
Routing & Frameworks
![Page 16: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/16.jpg)
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?
![Page 17: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/17.jpg)
Planning - Rube Goldberg of Software
![Page 18: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/18.jpg)
Planning - The Forum Conundrum
![Page 19: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/19.jpg)
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)
})
![Page 20: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/20.jpg)
Deployment - Upgrading
What happens when I try to upgrade?
Chance of
Conflict
Time
![Page 21: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/21.jpg)
Angular
![Page 22: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/22.jpg)
Planning - Google did it!
![Page 23: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/23.jpg)
Planning - Weighing In
![Page 24: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/24.jpg)
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.
![Page 25: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/25.jpg)
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();
});
![Page 26: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/26.jpg)
Development - A Growing Stack
Data Access
Service Layer and Business Logic
API Controller
Angular Service
Angular ControllerClient
Server
![Page 27: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/27.jpg)
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);
}])
);
});
![Page 28: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/28.jpg)
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
![Page 29: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/29.jpg)
Node.js
![Page 30: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/30.jpg)
Planning - Resource Management
Now that I use the same language across the entire stack hiring just got simpler.
![Page 31: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/31.jpg)
Planning - Resource Management
![Page 32: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/32.jpg)
Planning - Adoption
Big names are jumping on board:
● Walmart Labs
● PencilBlue
http://nodejs.org/industry/
![Page 33: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/33.jpg)
Development - Node Inspector
![Page 34: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/34.jpg)
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
![Page 35: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/35.jpg)
Deployment - Shooting for the Cloud
Elastic Beanstalk OpenShift Nodejitsu Bluemix
Linode Heroku
![Page 36: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/36.jpg)
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
![Page 37: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/37.jpg)
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...
![Page 38: I Know It Was MEAN, But I Cut the Cord to LAMP Anyway](https://reader033.vdocument.in/reader033/viewer/2022042817/55a6876e1a28ab501e8b45c5/html5/thumbnails/38.jpg)
The choice is yours but...