31
Server Check.in Node.js Case Study by Jeff Geerling

Server Check.in - Node.js and Drupal Working Together

Embed Size (px)

DESCRIPTION

This presentation was given to the STL.JS meetup group on May 15, 2014: http://www.meetup.com/STL-JS-meetup/events/151436472/ "Midwestern Mac, LLC has integrated a small, scalable Node.js application into their Drupal-powered Server Check.in service. Jeff will take us on an exploration of integrating the two platforms, and explain how this work has enabled the service to scale to hundreds of thousands of ICMP ping and HTTP status checks per day."

Citation preview

Page 1: Server Check.in - Node.js and Drupal Working Together

Server Check.inNode.js Case Study by Jeff Geerling

Page 2: Server Check.in - Node.js and Drupal Working Together

Jeff Geerling

• jeffgeerling.com / geerlingguy • Senior Application Developer, Mercy • Owner, Midwestern Mac, LLC

Page 3: Server Check.in - Node.js and Drupal Working Together

Agenda

• About the service

• A love story (Drupal + Node.js)

• Hosting, Marketing, Monitoring

• Q&A

Page 4: Server Check.in - Node.js and Drupal Working Together

Why build another uptime monitor?

Page 5: Server Check.in - Node.js and Drupal Working Together

Why build another uptime monitor?

Page 6: Server Check.in - Node.js and Drupal Working Together

Server Check.in

• Dogfood project

• Simple, cheap, reliable service

• Notify me when my servers are down

• Launched December, 2012

https://servercheck.in @servercheckin

Page 7: Server Check.in - Node.js and Drupal Working Together

Demo

Page 8: Server Check.in - Node.js and Drupal Working Together

External Services

• Twilio

• Stripe

• Disqus

Page 9: Server Check.in - Node.js and Drupal Working Together

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

Page 10: Server Check.in - Node.js and Drupal Working Together

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

(for payment processing)

Page 11: Server Check.in - Node.js and Drupal Working Together

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

(for payment processing)

(for comments)

Page 12: Server Check.in - Node.js and Drupal Working Together

External Code/Libraries• Flot (jQuery graphing library)

!

!

• MailChimp email templates

!

Page 13: Server Check.in - Node.js and Drupal Working Together

♥+

Page 14: Server Check.in - Node.js and Drupal Working Together

Server Checking• Originally: DB Queue + multithreaded cron batch

• Problems:

• Wasn’t scaling with growth

• Synchronous server checking via PHP cURL (slow even with 8-16 threads)

• 10 min interval maximum

Page 15: Server Check.in - Node.js and Drupal Working Together

Server Checking

Source: https://servercheck.in/blog/moving-functionality-nodejs-increased-server

Page 16: Server Check.in - Node.js and Drupal Working Together

Server Checking

Source: https://servercheck.in/blog/moving-functionality-nodejs-increased-server

10s 3s 5s 1s 7s

26 seconds total

Page 17: Server Check.in - Node.js and Drupal Working Together

Server Checking

Source: https://servercheck.in/blog/moving-functionality-nodejs-increased-server

10s 3s 5s 1s 7s

26 seconds total

10s 3s 5s 1s 7s

10 seconds total

Page 18: Server Check.in - Node.js and Drupal Working Together

Server Checking

Source: https://servercheck.in/blog/moving-functionality-nodejs-increased-server

Asynchronous tasks can be done in PHP (or many other languages), but Node.js makes them easier.

10s 3s 5s 1s 7s

26 seconds total

10s 3s 5s 1s 7s

10 seconds total

Page 19: Server Check.in - Node.js and Drupal Working Together

Server Checking

• Now: External Node.js application

• Allows:

• Scalability, geographically-diverse checking

• Servers are checked asynchronously

• 1 minute check intervals for everyone (yay!)

Page 20: Server Check.in - Node.js and Drupal Working Together
Page 21: Server Check.in - Node.js and Drupal Working Together

Server Check Overview• Drupal!

• Callback - JSON list of servers to check

• Callback - accept POST of JSON server check result data

• Node.js!

• Cron-based mini app:

• retrieve list of servers

• check all servers (async)

• post batch of data back to Drupal

Page 22: Server Check.in - Node.js and Drupal Working Together

Code

Page 23: Server Check.in - Node.js and Drupal Working Together

• For HTTP requests: mikeal/request

• For ICMP pings: geerlingguy/jjg-ping

• For Async control flow: caolan/async

Page 24: Server Check.in - Node.js and Drupal Working Together

Hosting on the Cheap• Cheap Low End Box servers (~$15/year VPS)

• Main need: geographically-diverse, decent network I/O - not CPU, disk, reliability, etc.

• Infrastructure managed with Ansible

• New servers in < 10 min. (aside: check out Ansible for DevOps)

• Cheap service + cheap servers + frequent changes == 99.9% uptime?

• (testing + automation == reliability)

Page 25: Server Check.in - Node.js and Drupal Working Together

Launch / Marketing

“If you build it, they will come.”

Page 26: Server Check.in - Node.js and Drupal Working Together

Launch / Marketing

“If you build it, they will come.”

Page 27: Server Check.in - Node.js and Drupal Working Together

Launch / Marketing• Some things I’ve tried:

• Drupal.org case study

• Hacker News post

• Sponsoring blogs

• Blogging (servercheck.in/blog)

• Keep trying new things!

Page 28: Server Check.in - Node.js and Drupal Working Together

Metrics - CRM/Dashboard

Track important metrics!

Page 29: Server Check.in - Node.js and Drupal Working Together

Metrics - Munin

Monitor resource usage!

Page 30: Server Check.in - Node.js and Drupal Working Together

Summary• Drupal/PHP is a solid platform for user-based

web applications

• Node.js is a solid platform for lightweight asynchronous, I/O-heavy work

• And maybe more…

• You can do a lot with a little (hosting, marketing, monitoring)

Page 31: Server Check.in - Node.js and Drupal Working Together

Thanks!

(Use coupon code STL14 for 20% off!)

• More Resources:

• Simple Node.js Dev VM (Ansible + Vagrant)

• Server Check.in Blog / @servercheckin

• Ansible for DevOps