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

  • View
    2.341

  • Download
    0

  • Category

    Software

Preview:

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

Server Check.inNode.js Case Study by Jeff Geerling

Jeff Geerling

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

Agenda

• About the service

• A love story (Drupal + Node.js)

• Hosting, Marketing, Monitoring

• Q&A

Why build another uptime monitor?

Why build another uptime monitor?

Server Check.in

• Dogfood project

• Simple, cheap, reliable service

• Notify me when my servers are down

• Launched December, 2012

https://servercheck.in @servercheckin

Demo

External Services

• Twilio

• Stripe

• Disqus

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

(for payment processing)

External Services

• Twilio

• Stripe

• Disqus

(for sms notifications)

(for payment processing)

(for comments)

External Code/Libraries• Flot (jQuery graphing library)

!

!

• MailChimp email templates

!

♥+

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

Server Checking

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

Server Checking

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

10s 3s 5s 1s 7s

26 seconds total

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

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

Server Checking

• Now: External Node.js application

• Allows:

• Scalability, geographically-diverse checking

• Servers are checked asynchronously

• 1 minute check intervals for everyone (yay!)

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

Code

• For HTTP requests: mikeal/request

• For ICMP pings: geerlingguy/jjg-ping

• For Async control flow: caolan/async

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)

Launch / Marketing

“If you build it, they will come.”

Launch / Marketing

“If you build it, they will come.”

Launch / Marketing• Some things I’ve tried:

• Drupal.org case study

• Hacker News post

• Sponsoring blogs

• Blogging (servercheck.in/blog)

• Keep trying new things!

Metrics - CRM/Dashboard

Track important metrics!

Metrics - Munin

Monitor resource usage!

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)

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

Recommended