51
Node.js Micro- Services at IBM Dejan Glozic, IBM nodeconf.eu 2014

Node and Micro-Services at IBM

Embed Size (px)

DESCRIPTION

Slides for the presentation at the nodeconf.eu conference in Waterford, Ireland on Sept 8, 2014.

Citation preview

Page 1: Node and Micro-Services at IBM

Node.js Micro-Services at IBM

Dejan Glozic, IBM nodeconf.eu 2014

Page 2: Node and Micro-Services at IBM

About me

Dejan Glozic, Full-Stack Architect

IBM Canada Toronto Laboratory

@dglozic

http://dejanglozic.com

Page 3: Node and Micro-Services at IBM

Disclaimer: I don’t speak for the entire IBM

Just my cozy corner in IBM Rational

Page 4: Node and Micro-Services at IBM
Page 5: Node and Micro-Services at IBM
Page 6: Node and Micro-Services at IBM

Our storyWhy we chose micro-services and Node.js

Page 7: Node and Micro-Services at IBM

–Gerrald Mast, The Comic Mind: Comedy and the Movies, 1973

Boy meets girl, boy looses girl, boy recovers true love.

Page 8: Node and Micro-Services at IBM

The new cliché• Boy builds a monolith quickly (because MVP)

• Boy bloats the monolith with features

• Boy makes a big ball of mud

• Boy rewrites the system using small services

• Boy cannot shut up about it at conferences

Page 9: Node and Micro-Services at IBM

We used micro-services before they were cool

We just called them ’12-factor apps’.

Page 10: Node and Micro-Services at IBM

1 4 12CONCEPT TENETS FACTORS

Page 11: Node and Micro-Services at IBM

Our first Node.js service

We needed a good enough reason

Page 12: Node and Micro-Services at IBM

We were sitting on the fenceI have a blog post to prove it

Page 13: Node and Micro-Services at IBM

What made us bite the bullet?

NodeSummit 2013 - Walmart, Groupon, PayPal, Yahoo

Page 14: Node and Micro-Services at IBM
Page 15: Node and Micro-Services at IBM
Page 16: Node and Micro-Services at IBM

It is not hard to build one app

For two or more, you need an actual architecture

Page 17: Node and Micro-Services at IBM

Our key tenets

1. Many micro-services instead of a monolith

2. Deploy micro-services independently

3. Communicate using message queues

4. Cluster locally

Page 18: Node and Micro-Services at IBM

1. Many micro-services

Down with the monolith!

Page 19: Node and Micro-Services at IBM

We used to build monoliths

Practically a must on-premise

Page 20: Node and Micro-Services at IBM

The cloud changed everything

Bizarro world - everything good on premise is bad in the cloud

Page 21: Node and Micro-Services at IBM

Borg collectiveBreak a large system into manageable chunks. Say,

using Node.js.

Page 22: Node and Micro-Services at IBM
Page 23: Node and Micro-Services at IBM

Small services are Node.js’ sweet spot

There is a reason for the hexagon icon (you know, bee hive?)

Page 24: Node and Micro-Services at IBM

Monolith antibodiesIt takes a gigantic effort NOT to arrive at a micro-service

system using Node.js

Page 25: Node and Micro-Services at IBM

Node.js is a great candidate

• Miserly on the resources

• Component model + NPM

• Great test and build tools (e.g. JSHint, Mocha, Grunt)

• Easy to write (and completely rewrite)

Page 26: Node and Micro-Services at IBM

2. Deploy micro-services independently

No maintenance downtime

Page 27: Node and Micro-Services at IBM

No budget for big outages

Need to fix and evolve the system in mid-flight

Page 28: Node and Micro-Services at IBM

Node.js is a great candidate

• Services start and stop in seconds

• Tools to keep the services up (e.g. PM2)

• PaaS-friendly (we use Bluemix)

• Clustering is great for rolling deploys

Page 29: Node and Micro-Services at IBM

3. Message brokersBecause there is life beyond REST

Page 30: Node and Micro-Services at IBM

REST uses request/response pattern

This makes micro-service systems too ‘chatty’.

Page 31: Node and Micro-Services at IBM

Test: review firewall rules

The more IPs listed, the chattier the service.

Page 32: Node and Micro-Services at IBM

Alternative: event collaboration

State changes are published into topics, interested services subscribe to them.

Page 33: Node and Micro-Services at IBM

Advantages• No wasted requests (are we there yet?)

• Resiliency (fire and forget)

• Safety valve

• Loose coupling of services

• Enables server push

Page 34: Node and Micro-Services at IBM

Messaging exampleRabbitMQ between micro-services, WebSockets for

server push

Page 35: Node and Micro-Services at IBM

Node.js is a great candidate

• Great support for MQ protocols (MQTT, AMQP)

• Async processing of incoming messages

• Great support for WebSockets (server push)

Page 36: Node and Micro-Services at IBM

4. Local clusteringBecause load is rarely uniform

Page 37: Node and Micro-Services at IBM

Concerns

• Apply extra capacity where it matters

• Evolve the system as needed

• Vertical vs horizontal scaling

• HA vs scaling

Page 38: Node and Micro-Services at IBM

Node.js is a great candidate

• Single threaded event loop

• ‘Share nothing’ from day 1

• Local clustering to use multiple cores

• Load balancing across VMs for horizontal scaling

Page 39: Node and Micro-Services at IBM

MQ clusteringRabbitMQ worker queue, round-robin to micro-service

workers

Page 40: Node and Micro-Services at IBM

Truth in advertisingOther people develop micro-services using Java/Netty or

Scala/Akka or Go

Page 41: Node and Micro-Services at IBM

Node.js is (still) a great candidate

• Browsers running JS give Node.js an edge

• Express or Hapi make API services easy

• NoSQL DBs with JSON (JS all the way down)

• Developer happiness

Page 42: Node and Micro-Services at IBM

(More) Truth in advertising

We have some battle scars to show

Page 43: Node and Micro-Services at IBM

Legal hates usYou want us to vet how many modules again?

Page 44: Node and Micro-Services at IBM

Ops hate usYou need how many VMs, again?

Page 45: Node and Micro-Services at IBM

We get PaaS now Luckily we can move from SoftLayer we own to Bluemix

we also own.

Page 46: Node and Micro-Services at IBM

SSO is hard Nontrivial to make a federated system secure yet

transparent.

Page 47: Node and Micro-Services at IBM

Composition is hard Stitching a page from several micro-services is non-

trivial (yeah, yeah, Web Components HTML Imports…)

Page 48: Node and Micro-Services at IBM

We have no regretsAs Ralph Wiggum would say, “We are learnding!"

Page 49: Node and Micro-Services at IBM
Page 50: Node and Micro-Services at IBM

Questions?

Page 51: Node and Micro-Services at IBM

Thank you!@dglozic

http://dejanglozic.com