Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active December 30, 2015 09:59
Show Gist options
  • Save jmervine/7812551 to your computer and use it in GitHub Desktop.
Save jmervine/7812551 to your computer and use it in GitHub Desktop.

Beyond the MEAN stack

Presenter:

@othiym23

github.com/othiym23

MEAN

  • MongoDB
  • Express
  • Angular.js
  • Node.js

Let it go.

Software Core Values

  • low coupling
  • high cohesion

Web Development is more pattern-driven:

  • is this social media?
  • is this a storefront?
  • is this... is this a CMS?

Node loves modules:

  • more all the time
  • available for almost every use case
  • pretty easy to understand
  • (mostly) on Github
  • (mostly) freely usable

Stacks: khakis of the internet

  • familiar: faster to build things your already know
  • comforting: already integrated

Problems

  • opaque: full of implicit assumptions and requirements
  • complicated: hard to master, easy to break
  • monolithic

"Node says: build only what you need."

"Node is NOT one size fits all."

"[Node] It's not a swiss army chainsaw."

Node Uses

  • streaming
  • JSON APIs
  • multiplexing
  • soft real-time
  • proxying
  • .. you know, fast web servers

& some legacy glue

  • dat: scraping & ETL
  • dinosaur taming: Oracle & XML
  • ~50K modules

the zen of Node

  • self-contained: code over configuration
  • modular: inversion of control & direct dependency injection
  • simple: one small thing in one short file
  • AND SO: easy for new people to pick up, easy to maintain

M(ongoDB)

  • Redis
  • MySQL (or Postgres)
  • Couch
  • LevelDB

E(xpress)

  • hapi
    • plugins instead of middleware
    • configuration-centric
    • optimized for large teams
    • grew out of express
  • Restify
    • API "compatible" with Express
    • meant for building RESTful APIs
    • optimized for JSON
    • instrumented for operational monitoring (via DTrace)
  • Sails
    • actually built on top of Express
    • feels like Rails (including scaffolding)
    • real-time
    • stack-like, but still a create of parts

A(ngularJS) (or E: Ember)

  • browserify
    • puts node modules in your browser
    • puts node ideology in your browser
    • everything's on npm
    • flexible packaging pipeline
    • good for the Node-first developers
  • component
    • similar to browserify
    • built on GitHub
    • not so much with the asset pipeline
    • more focused on the client-side development than browserify
  • bower / Yeoman
    • integrated, browser focused workflow

N(ode.js)

  • Not every problem is well solved by Node.

"Choose the tool that will help you solve the problems at hand."

  • PHP can scale for simple pages.
  • Java (Scala, etc.) can do big workflows and XML data better.
  • If you're on Window's, it's not always better to switch...

Node Future Releases

v0.12

What might be broken?

  • Staying up to date with v8.
  • Native (C++) modules will need to be updated.
  • Will release step by step guide to update.
  • Node core team is dedicated to backwards compatibility.
  • OS level load balancing on Linux via cluster module. Yay!
    • Currently not great at evenly distrubuting connections currently.
  • Streams; 'old mode' replated with 'flowing mode' and 'paused mode'.
  • Full multi-context support, two Node processes on the same event loop.

API additions

  • writev w/ cork() and uncork() -- small message grouping.
  • smalloc(ate); buffer memory allocation
    • Why? Performance enchancement.
  • execSync() and spawnSync()
  • AsyncListener API; low level binding that allows developers to know the current state of all requests
  • profile CPU, analyse the heap and track garbage collection

v0.13?

  • Focused on performance and stability.
  • See checklist on gh issue #6252

Security Panel Notes

  • Locking versions can be detrimental to security, patches beget security fixes.
  • Know your core modules, watch for patches.
  • Follow https://groups.google.com/forum/#!forum/nodejs-sec
  • Follow @nodesecurity on Twitter
  • Patch node version quickly.
  • Stay edge, currently no security back patching to previous version.
  • Ask GitHub to allow for private issues ion public repos so security issues can be reported discreetly.
  • Add SECURITY.md files to public repos with information on how to privately report security issues.

Node Panel

  • LinkedIn deploys 2-3 times a day.
  • LinkedIn, Groupon developers deploy changes on the fly.

Riding the N(ode) Train

Part 1

Arch was broken due to bad decisions and changing market.

  • US and EU used different archs.
  • Moving towards being a mobile company.
  • Slow velocity.
  • Slow deployment.
  • Lack of Mobile and Web parity.

Part 2: Rewrite

Monolithic RoR -> (Deals) (etc.) (etc.)

Should

  • be build on APIs
  • easy to find Devs
  • allow teams to work separately
  • allow teams to deploy their own code
  • allow for global designed changes

Failings

  • New design on Monolith
  • Changing many things at once
  • Feature performance evaluation

Evaluated

  • Node
  • MRI Ruby/Rails, Sinatra
  • JRuby/Rails, Sinatra
  • Java/Play, Java/Vertx
  • Python + Twisted
  • PHP

Why Node?

  • Community
  • NPM
  • Easier to hire JS devs.
  • minimum viable performance
  • scaling (process model)

Note:

Throttle up the number of outgoing http connections per process.

http.globalAgent.maxSockets = Number.MAX_VALUE;

Part 3: Performance

Note:

Uses documentReady as perceived user performance.

Disrupting traditional database architectures with Node.js

Speaker: Jim Mittler

Current Architecture

  • Publish -> Table / Query <-z-> Client
  • All real time BI has some latency; 1m, 5m, etc.

Reboot

  • Analytics should be delivered in real-time.
  • Web based "subscriber" modeled after message push
  • Deliver the aggregated analytic results
  • Highly useful for exec dashboards, retail analytics, mobile real-time updates and more.

Node DB solution

  • RTDB: real-time (json document) database.
  • RESTful inserts -- no native driver (pure rest).
  • Analytics are made available via map/reduce.
  • Filters and queries have to be pre-loaded, doesn't support dynamic (e.g. SQL) queries.
  • When data changes, queries are updated in real-time and subscribers are updated immediately using HTML5 server-sent events.
  • Arch:
    • Publisher -> Collection / Query <--> Subscriber
  • Sits on top of data store; e.g. Mongo, MySQL, Oracle, etc.
  • M/R performed incrementally, doesn't remap on inserts.
  • User specific filter/function.

Note: checkout 'symmerty' NPM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment