Building a Real-Time Cloud Analytics Service with Node.js



Similar documents
When Node.js goes wrong: Debugging Node in production. Surge 2012 David Pacheco Joyent

PROFESSIONAL. Node.js BUILDING JAVASCRIPT-BASED SCALABLE SOFTWARE. Pedro Teixeira WILEY. John Wiley & Sons, Inc.

ntopng: Realtime Network Traffic View

FIVE SIGNS YOU NEED HTML5 WEBSOCKETS

MAGENTO HOSTING Progressive Server Performance Improvements

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

Shoal: IaaS Cloud Cache Publisher

Rackspace Cloud Databases and Container-based Virtualization

Java Monitoring. Stuff You Can Get For Free (And Stuff You Can t) Paul Jasek Sales Engineer

An Oracle White Paper July Oracle Primavera Contract Management, Business Intelligence Publisher Edition-Sizing Guide

Resource Utilization of Middleware Components in Embedded Systems

Assignment One. ITN534 Network Management. Title: Report on an Integrated Network Management Product (Solar winds 2001 Engineer s Edition)

Load Testing RIA using WebLOAD. Amir Shoval, VP Product Management

4D and SQL Server: Powerful Flexibility

An Oracle White Paper September Advanced Java Diagnostics and Monitoring Without Performance Overhead

TCP Servers: Offloading TCP Processing in Internet Servers. Design, Implementation, and Performance

Cisco PIX vs. Checkpoint Firewall

Power Tools for Pivotal Tracker

MEASURING WORKLOAD PERFORMANCE IS THE INFRASTRUCTURE A PROBLEM?

socketio Documentation

Oracle Communications WebRTC Session Controller: Basic Admin. Student Guide

ELIXIR LOAD BALANCER 2

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

Part V Applications. What is cloud computing? SaaS has been around for awhile. Cloud Computing: General concepts

Unibet.com Architecture

PTC System Monitor Solution Training

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft Internet Information Services Agent Version Fix Pack 2.

Titolo del paragrafo. Titolo del documento - Sottotitolo documento The Benefits of Pushing Real-Time Market Data via a Web Infrastructure

White Paper. How to Achieve Best-in-Class Performance Monitoring for Distributed Java Applications

Load and Performance Load Testing. RadView Software October

A Brief. Introduction. of MG-SOFT s SNMP Network Management Products. Document Version 1.3, published in June, 2008

SiteCelerate white paper

Monitoring the Real End User Experience

EWeb: Highly Scalable Client Transparent Fault Tolerant System for Cloud based Web Applications

How To Monitor A Server With Zabbix

What s Cool in the SAP JVM (CON3243)

AMAZON S3: ARCHITECTING FOR RESILIENCY IN THE FACE OF FAILURES Jason McHugh

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

Zing Vision. Answering your toughest production Java performance questions

Mark Bennett. Search and the Virtual Machine

How To Monitor And Test An Ethernet Network On A Computer Or Network Card

Performance Management in a Virtual Environment. Eric Siebert Author and vexpert. whitepaper

OpenFlow Based Load Balancing

How to analyse your system to optimise performance and throughput in IIBv9

Cloud Computing for Control Systems CERN Openlab Summer Student Program 9/9/2011 ARSALAAN AHMED SHAIKH

White Paper. How Streaming Data Analytics Enables Real-Time Decisions

Technical Overview Simple, Scalable, Object Storage Software

Stop the Guessing. Performance Methodologies for Production Systems. Brendan Gregg. Lead Performance Engineer, Joyent. Wednesday, June 19, 13

AjaxScope: Remotely Monitoring Client-side Web-App Behavior

SOLUTION BRIEF: SLCM R12.7 PERFORMANCE TEST RESULTS JANUARY, Load Test Results for Submit and Approval Phases of Request Life Cycle

Troubleshooting BlackBerry Enterprise Service 10 version Instructor Manual

All You Can Eat Realtime

Integrating Web Messaging into the Enterprise Middleware Layer

Drupal Performance Tuning

Responsive, resilient, elastic and message driven system

Data Driven Success. Comparing Log Analytics Tools: Flowerfire s Sawmill vs. Google Analytics (GA)

How To Write A Web Server In Javascript

Web Server Software Architectures

Scaling Progress OpenEdge Appservers. Syed Irfan Pasha Principal QA Engineer Progress Software

EView/400i Management Pack for Systems Center Operations Manager (SCOM)

HIGH-SPEED BRIDGE TO CLOUD STORAGE

Instrumentation Software Profiling

Simple Tips to Improve Drupal Performance: No Coding Required. By Erik Webb, Senior Technical Consultant, Acquia

PANDORA FMS NETWORK DEVICE MONITORING

Performance testing Web 2.0

CS555: Distributed Systems [Fall 2015] Dept. Of Computer Science, Colorado State University

Example of Standard API

Measuring CDN Performance. Hooman Beheshti, VP Technology

ZEN LOAD BALANCER EE v3.02 DATASHEET The Load Balancing made easy

IERG 4080 Building Scalable Internet-based Services

Cloud Computing Trends

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

Understanding Evolution's Architecture A Technical Overview

Monitoring applications in multitier environment. Uroš Majcen A New View on Application Management.

Achieving Zero Downtime and Accelerating Performance for WordPress

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

NMS300 Network Management System

Contents Introduction... 5 Deployment Considerations... 9 Deployment Architectures... 11

Achieving Real-Time Business Solutions Using Graph Database Technology and High Performance Networks

TFE listener architecture. Matt Klein, Staff Software Engineer Twitter Front End

CORD Monitoring Service

Application Performance Monitoring (APM) Technical Whitepaper

Integrating Mobile apps with your Enterprise

Top 10 Tips for z/os Network Performance Monitoring with OMEGAMON Session 11899

Determine the process of extracting monitoring information in Sun ONE Application Server

System Architecture V3.2. Last Update: August 2015

EVERYTHING A DBA SHOULD KNOW

WhatsUp Gold v11 Features Overview

Basic & Advanced Administration for Citrix NetScaler 9.2

Effective Java Programming. measurement as the basis

VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook

Data Visualization Frameworks: D3.js vs. Flot vs. Highcharts by Igor Zalutsky, JavaScript Developer at Altoros

User Identification (User-ID) Tips and Best Practices

Configuring Nex-Gen Web Load Balancer

DEPLOYMENT GUIDE Version 1.1. Configuring BIG-IP WOM with Oracle Database Data Guard, GoldenGate, Streams, and Recovery Manager

Network Infrastructure Services CS848 Project

Transcription:

Building a Real-Time Cloud Analytics Service with Node.js Surge 2011 David Pacheco (@dapsays) Bryan Cantrill (@bcantrill)

Last year at #surgecon... Last year, we described the emergence of real-time data semantics in web-facing applications a trend that we dubbed data-intensive real-time (DIRT) We discussed some of the ramifications of DIRT among them the need to observe the stack in production in terms of latency After Surge 2010, we got to work on a facility to do this... The facility cloud analytics was first stood up as a production service at Joyent in March and shipped as a product in April Over the year, we have continued to deploy and improve it Cloud analytics is itself a DIRTy application; our implementation and our production experiences may inform decisions for other DIRTy apps 2

Agenda Design objective Architecture overview Design choices Production experiences 3

Design objective Need to focus on the source of the pain: latency How long a synchronous operation takes... while a client is waiting for data... while a user is waiting for a page to load Need to allow for ad hoc instrumentation Need to summarize the latency of thousands of operations without losing critical detail Need to summarize that across a distributed system Need to do this in real time 4

Visualizing latency as a scalar? Visualizing latency as a scalar (e.g., average) hides outliers but in a real-time system, it is the outliers that you care about! Using percentiles is better, but still hides crucial detail 5

Visualizing latency as a heatmap? x-axis = time, y-axis = latency, z-axis (color saturation) = count Many patterns are now visible (as in this example of MySQL query latency), but critical detail is still missing 6

Visualizing latency as a 4D heatmap Hue can be used to express higher dimensionality x-axis = time, y-axis = latency, color saturation = count, color hue = additional dimension (database table in this example) 7

Agenda Design objective Architecture overview Design choices Production experiences 8

Architectural components configuration service: manages which metrics are gathered instrumenter: uses DTrace to gather metric data one per compute node, not per OS instance reports data at 1Hz, summarized in-kernel aggregators: combine metric data from instrumenters client: presents metric data retrieved from aggregators 9

Architectural overview Compute node Datacenter headnode Instrumenter Configuration service Compute node Instrumenter Aggregators (multiple instances for parallelization) Compute node Instrumenter 10

Step 1: User creates an instrumentation HTTP user/api request: create instrumentation Compute node Datacenter headnode Instrumenter Configuration service AMQP: create Compute node AMQP: create Instrumenter Aggregators (multiple instances for parallelization) Compute node Instrumenter 11

Step 2: Instrumenters report data Compute node Datacenter headnode Instrumenter Configuration service Compute node Instrumenter Aggregators (multiple instances for parallelization) Compute node AMQP: raw data (repeat @1Hz) Instrumenter 12

Step 3: Users retrieve data HTTP user/api request: retrieve data Compute node Datacenter headnode Instrumenter Configuration service Compute node HTTP: retrieve Instrumenter Aggregators (multiple instances for parallelization) Compute node Instrumenter 13

Inside the instrumenter Config service (Node.js) Aggregators (Node.js) AMQP Config Data Other compute nodes Instrumenter (Node.js) Virtual OS Virtual Machine dtrace backend Virtual Machine Virtual OS node-libdtrace libdtrace Virtual OS Virtual Machine.d data DTrace (kernel) 14

Agenda Introduction Architecture overview Design choices Production experiences 15

Node.js node.js is a JavaScript-based framework for building eventoriented servers: var http = require( http ); http.createserver(function (req, res) { res.writehead(200, {'Content-Type': 'text/plain'}); res.end('hello World\n'); }).listen(8124, "127.0.0.1"); console.log( Server running at http://127.0.0.1:8124! ); 16

The energy behind Node.js node.js is a confluence of three ideas: JavaScriptʼs rich support for asynchrony (i.e. closures) High-performance JavaScript VMs (e.g. V8) Solid system abstractions (i.e. UNIX) Because everything is asynchronous, node.js is ideal for delivering scale in the presence of long-latency events 17

Why Node.js Our previous experience: building complex multi-threaded systems in C Event-oriented model sounds pretty appealing Event-oriented is possible in C, easier in Node.js Why Node.js: minimize latency between gathering data and serving it to clients (especially in the face of service failure) fast development Why not: Poor observability (no pstack, dtrace, mdb, debugger) Limited static analysis tools (compared to C compiler and lint) No postmortem debugging At the very least, good choice for prototype. If it didn t work out, we wanted to know why. 18

Why AMQP Why messaging? Decouples system components Why AMQP? Standard protocol with existing libraries, servers, and tools Why rabbitmq? We were already using it elsewhere Reputation of reliability and performance Why not? Single broker = performance bottleneck Wanted to quantify that before choosing a more complex architecture 19

Why HTTP/JSON Obviously: universal language for web APIs Both browsers and Node.js have (mostly) first-class support for both HTTP and JSON But why not WebSockets? Actually, why WebSockets? Usual answer: polling is inefficient TCP connection overhead (obviated by HTTP keep-alive) HTTP header processing (hard to imagine being a performance problem) Extra request processing (not applicable to us) Since our data is essentially continuous, buffered at 1-second intervals...... there s no extra request overhead. Polling is actually what we want. Cons of WebSockets Complexity Observability (how do you measure server-side latency?) Awkward model for historical (non real-time) data We d want to quantify the performance problem before introducing this complexity 20

Why DTrace Comprehensive tracing of both kernel and application-level events in real-time Scales arbitrarily with: number of events (in situ aggregation) number of customer instances (global visibility, OS-level virtualization) Suitable for production systems Safe Minimal overhead Zero disabled probe effect Extensible via SDT, USDT (It s also the only game in town.) 21

Client-side vs. server-side rendering Line graphs: client retrieves raw data, renders graphs using flot, d3, etc. Heatmaps: client retrieves heatmap image generated on-the-fly by the server Con: lots of compute (requires parallelizing aggregators, but that s actually easy) Con: makes rich interaction somewhat more difficult Pro: heatmap is itself the most compact representation of the data 22

Agenda Design objective Architecture overview Design choices Production experiences 23

Problem: Node.js C++ add-ons We need Node.js add-ons (native extensions) for DTrace, kstat, libpng,... Add-ons are written in C++, which has no stable binary interface node and its add-ons must be built with the same compiler and version (or suffer nasty consequences!) Solution: CA delivers a bundle with node plus binary add-ons WAF-based build process is easy to get wrong e.g., build process looking in wrong place for header files e.g., binaries built without links to dependent libraries (fail at runtime) All we can do is fix these problems when we run into them, but it can be painful. 24

Problem: Node.js limits Each aggregator s load could be limited by size of the Node heap Each aggregator s load could be limited by 1 CPU (heatmap generation) Solution: parallelize workload at instrumentation level Spin up ncpus aggregators Each new instrumentation gets assigned randomly to one aggregator, which stores the data and services all requests for raw data and heatmap Config service proxies HTTP requests to the appropriate aggregator 25

Problem: Node.js observability Hard to figure out what a program is doing (or did do) Solutions: we built several tools to help with this: cactl: uses AMQP to ping, status-check, or summarize the state of all CA services amqpsnoop: watch all AMQP messages, or filter by arbitrary criteria (works only for messages on topic exchanges) node-panic: primitive postmortem debugging for Node.js When a server crashes or does the wrong thing, it must be possible to dump all state immediately so you can restart the service and debug later cactl can also send the command to panic via AMQP We also use snoop and Wireshark to understand network traffic 26

Problem: observing spinning programs Shortly after first production deployment, we found one of the aggregators spinning Not responding to AMQP or HTTP, not invoking system calls pstack showed it was running JavaScript, but we had no way of seeing what it was running No event loop => couldn t trigger panic via AMQP No event loop => couldn t use SIGUSR1 to start the debugger agent Several ways to improve this: Mitigation: Randomize aggregator selection to mitigate failure mode Solution: Change Node.js SIGUSR1 to open debugger port immediately Solution: Created ncore tool as part of node-panic to use SIGUSR1 to generate dump (including stacktrace!) of program stuck in infinite loop Solution (future): jstack() DTrace action Scary part: we haven t ever seen this problem since. 27

Problem: synchronous DTrace enabling DTrace can take several seconds to enable probes on a system Currently, this operation is synchronous in node-libdtrace, so instrumenters report no data while this is going on Challenging to make this async because libdtrace only supports one concurrent compile at a time due to yacc limitation (!) Solution: eio_custom() and asynchronous interface 28

Node: The Good Parts Development was fast: Time to functional CA prototype: 2 weeks Time to production for CA: 4 months The prototype evolved significantly, but was never thrown out CPU, memory usage have not been a problem for aggregators or configsvc. Events (e.g., HTTP request) typically shown on screen within 2-3 seconds Raw value requests served within a few milliseconds Heatmap requests served around 50-75ms Component failures do not result in latency bubbles for everyone else Tools have given us adequate visibility into service status (and where they haven t, we ve built more tools) 29

Problem: AMQP exclusive queues AMQP allows queues to have an exclusive consumer, enforced by the broker What happens when that consumer crashes? What happens when that consumer s system crashes? Broker has no way of knowing. On restart, the consumer is rejected from its own queue. Possible solution: AMQP heartbeating (requires client support) Solution: when consumer sees RESOURCE_LOCKED error, it pings itself, waits a while, and tries again. Note: without AMQP, we d instead have problems managing connections to multiple components claiming to be the same service. 30

Problem: AMQP connectivity Components can get disconnected from the broker network failure, broker failure, server failure, or even configuration change Components must handle this while in the middle of sending data Solution: arbitrary write operations can fail with socket disconnected errors node-panic was crucial for understanding Node.js Socket state in these cases Components must detect this while idle Possible solution: AMQP heartbeating (requires client support) Solution: each component periodically pings itself Components must keep trying to reconnect and what do we do with messages sent in the meantime? Note: these problems exist with direct connections, too. 31

Problem: RabbitMQ performance with many bindings During first (largest) major production deployment, rabbitmq lost its mind 90+% CPU utilization (on a 16-way box) Forever-increasing memory utilization (upwards of 400MB) while queue lengths all zero No visibility into dark queue of internal work Spent over a week trying to reproduce in development Eventually reproduced by creating 1500+ bindings on a topic exchange and sending about 100 messages per second. Mitigation: use rabbit s management API to build monitoring tools Possible solution: upgrade rabbitmq to 2.4.0 or later for fast topic routing Solution: use direct exchange rather than topic exchange (breaks amqpsnoop) 32

AMQP: The Good Parts Per-component configuration is trivial: just needs the broker IP Routing key abstraction simplifies failure modes around component crashes With the topic routing issue worked around, rabbitmq has easily handled as much traffic as we ve thrown at it with low (enough) latency (~100ms) With the glaring exception of internally queued work, rabbit provides good observability into the state of the distributed system e.g., message traffic on queues and channels e.g., bindings and channels associated with each queue 33

Summary On the most important early decisions (Node.js, AMQP/RabbitMQ, HTTP/JSON, DTrace), we haven t regretted any of these choices. Many of the problems were not specific to these technologies Observability: a problem with just about everything but C Network failure: a problem whether using AMQP or direct connections Such limitations can be overcome (by building new tools and fixing the software) Some of these were inherent limitations... Node.js scaling past 1 thread (but that was very easy to work around in our case) Still believe it has been and will be much easier to address these problems than to make the alternatives work Overall goal is met: visualizing performance data in real-time Demo on production system or GTFO! 34

Appendix 35

References Tools node-panic: https://github.com/joyent/node-panic amqpsnoop: https://github.com/davepacheco/node-amqpsnoop javascriptlint: https://github.com/davepacheco/javascriptlint jsstyle: https://github.com/davepacheco/jsstyle Cloud Analytics http://dtrace.org/blogs/dap/2011/03/01/welcome-to-cloud-analytics/ http://dtrace.org/blogs/bmc http://dtrace.org/blogs/brendan http://dtrace.org/blogs/rm 36