using node.js to improve the performance of mobile apps and mobile web

53
Using Node.js to improve the performance of Mobile apps and Mobile web Tom Hughes-Croucher Jetpacks for Dinosaurs, LLC [email protected] @sh1mmer

Upload: tom-croucher

Post on 29-Jan-2018

19.731 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Using Node.js to improve  the performance of  Mobile apps and Mobile web

Using Node.js to improve the performance of

Mobile apps and Mobile web

Tom Hughes-CroucherJetpacks for Dinosaurs, LLC

[email protected]@sh1mmer

Page 2: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Who is Tom?

• Wrote W3C Standards

• 10+ years in the web industry

• Worked on projects for: Tesco, NASA, Walmart, MySpace, etc

• ~5 years at Yahoo! including .com

• Node team at Joyent

Scalable Server-Side Code with JavaScript

Tom Hughes-Croucher

NodeUp and Running

Page 3: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

• You probably shouldn't let Twitter name your company

• Clients include

• Walmart

• MySpace

• Various Fortune 500 companies

• Multiple stealth startups

Page 4: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

This is a talk about why cell phones suck.

Page 5: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 6: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Radio waves suck(at least compared to fibre or copper)

Page 8: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Radio vs. buildings

Page 9: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 10: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 11: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 12: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

http://www.webperformancetoday.com/2012/04/02/mobile-versus-desktop-latency/

Desktop Mobile

Page 13: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmerOokla/speedtest.net

via http://www.slideshare.net/patrickmeenan/velocity-2012-taming-the-mobile-beast/22

Page 14: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Effect of latency on servers

Page 15: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Shielding Frontends

Page 16: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

nginxhaproxy

ATSvarnish

frontends web services/ data

Page 17: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

var client = net.connect(80, domain, function() { client.write("GET / HTTP/1.1\r\n"); t1 = (new Date()).getTime(); });

client.on('end', function() { t2 = (new Date()).getTime(); output.write(domain + ' ' + ((t2-t1)/1000) + 's\n'); });

Page 18: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

macupdate.com 442.3uzai.com 403.658wired.jp 238.848facilisimo.com 205.159mycokerewards.com 202.757rbc.cn 192.354moviesmobile.net 183.157stop55.com 145.927dir.bg 137.982carrefour.fr 112.789sifyitest.com 111.171

Sample of Alexa 5000

Page 19: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Event-driven Frontends

Page 20: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Client → Server Server → DB

Computation Computation

Page 21: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Not an event frontend

Page 22: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 23: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Server

Page 24: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Request

Page 25: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 26: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Event-driven frontend

Page 27: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Place-holder

Page 28: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 29: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

SharedWork

Resources

Page 30: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Memory operations

Page 31: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

var x = "I am a string"

~1ns Running 1 instruction2ns Data from l1 cpu cache5ns Data from l2 cpu cache80ns Data from ram

Page 32: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 33: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Mobile latency

Page 34: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 35: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmerCat

100 Blue Whales

Page 36: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

"They went from running 15 servers with 15 instances (virtual servers) on each physical machine, to just four instances that can handle double the traffic."

http://venturebeat.com/2011/08/16/linkedin-node/

Page 37: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Not just simple applications

Page 38: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 39: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 40: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

First page load vs. Client MVC

Page 41: Using Node.js to improve  the performance of  Mobile apps and Mobile web
Page 42: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 44: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Bandwidth

Latency Device capability

Page 45: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Barfing data at 3G

Page 46: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 47: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 48: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Clientside templating

Page 49: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Page 50: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Node.js allows you to tune rendering between client and server based on the network.

Page 51: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

HTML JSON

More bandwidth

Less client processing

Less bandwidth

More client processing

Battery friendly Cheaper for you bandwidth/server

Cheaper for them bandwidth

Page 52: Using Node.js to improve  the performance of  Mobile apps and Mobile web

@sh1mmer

Summary

• Node.js allows you to:

• Manage resources with unreliable mobile data connections

• Choose where to apply rendering

• Pick the right rendering solution for the right scenario