Scalability Lessons

Danny MacAskill's Imaginate

Beyond 10K requests/second

Your Host Tonight

Image source: my 4 yo daughter

Software engineer at MediaSmart Mobile

alexfernandez, @pinchito, alejandrofer

Occasional scalability consultant

Guilty!

Image source: Stupid Zombies 2

We help pay for your entertainment

What We Do


Serve mobile ads


Performance campaigns


10K+ requests / second

5M+ impressions / day

25+ servers

8+ countries

From the particular to the abstract


  • Node.js and Scalability

  • Technical Challenges

  • Effective Engineering in the Cloud

  • Messaging and Caching Are your Friends

  • Scalability Tips

Is Node.js Fast?

Define ‘fast’

Source: GodTIC (Spanish)

So Why Node.js?


Asynchronous, event-driven, non-blocking


Focus on concurrency, not performance


Node behaves very linearly:

Double the load, double the resources


Smooth learning curve

Few surprises

What Is Scalability


Serve an increasing numbers of requests


  • with increasing resources

  • without degradation

  • cost-effectively



Scale Up vs Scale Out

vs

Image source: Rama

Image source: ZDNet

Linearity Rules!

Source: MediaSmart Mobile

Technical Challenges


Image source: usvsth3m

Callback Hell and Back


Escape the callback pyramid


Use named functions, not lambdas


Use events as they were meant to be


Would you bet your business on promises?

(Sorry about that)

Waiting for GENERATORs


Image source: Dr Electric

Unpaid Technical Debts Accumulate


Image source: Chelydra.org

Developments go slower

Your code runs slower

Managing Technical Debt


Business Goes First


Do not scale too soon

... and definitely not too late!


Keep lists of what you owe

and repay it as you go along


Don't let performance issues accumulate

Effective Engineering in the Cloud

    

Image source: Beao

... is just effective engineering

Load Testing


Gather data instead of opinions


Two kind of tests:


Measure requests per second

... and then correct by a given factor

Test to See Where It Breaks


Image source: MythBusters

But do not be afraid to work on production if needed

Deployment


DYOD: do your own deployments


Deploy as often as possible!


Monitor after deploying!

Monitor everything!


Send alerts

Avoid False Alarms


Image source: Laughing Squid

Send only necessary alerts

Humanity's Greatest Inventions

Image source: Josh Linkner

Beware Swiss Army Knives

Remote Caching


Humanity's best invention

for scalability


Cache everything everywhere!

Locally and remotely


Memcached + node-memcached

  Redis + redis driver

Database-Crowding Architecture


Memcached Architecture



Messaging

Humanity's second best invention

for scalability


Ideal for async processing


Remove work from online processing

and aggregate it


RabbitMQ + node-amqp

           Redis + redis driver

Sample RabbitMQ Architecture



Scalability Tips

Image source: CloudBees Blog

Locks are Evil

Always

No exceptions

            Source: Haretz

Search for lock-free solutions

Know your Bottlenecks

Scalability is about finding bottlenecks

Image source: BizarreRecords.com

Introduce your own bottlenecks: throttle down traffic

Avoid Unbounded Tasks

First order of business: bound your tasks


Set a target for optimizations

You Found the Cause...


Image source: glee wiki

Now look for the real cause!

Root Cause Analysis


Do root cause analysis immediately and fully


Farther away from symptom → less effective


Work on symptoms if needed


Why? why? why? why? why?

(The five whys)

50K+ Modules to Choose From


Source: modulecounts.com

Maven and Ruby: ~ six months away

Improve Your Wheels


Reinventing the wheel is stupid

Image source: Michael Covel

Building improved wheels is great!

A $6500 Wheel

Image source: Tesla Motors

Be Humble


The world doesn't care about your feelings


You cannot win an argument with reality


Unverified opinions are useless

(specially your own)


Accept facts and collect data

One More Thing


The great menace to progress is not ignorance

but the illusion of knowledge.

Daniel J. Boorstin


The teacher gets the most out of the lessons,

and the true teacher is a learner.

Elbert Hubbard

Thanks!


And now...


Image source: livluvcreate

Questions?

Thanks Again!










http://slid.es/alexfernandez/scalability-lessons