42
HOW TO SCALE YOUR APP AND WIN THE CLOUD CHALLENGE QUENTIN ADAM @ WAXZCE 2013

How to scale your app and win the cloud challenge

Embed Size (px)

DESCRIPTION

while42.org #1 paris event

Citation preview

Page 1: How to scale your app and win the cloud challenge

HOW TO SCALE YOUR APP AND WIN THE CLOUD CHALLENGEQUENTIN ADAM

@WAXZCE2013

Page 2: How to scale your app and win the cloud challenge

Quentin ADAM

Clever Cloud CEO

@waxzce on twitter

http://www.waxzce.org

WHO I AM ?

Page 3: How to scale your app and win the cloud challenge

Java, scala, python, nodejs, php… apps scaling automatically in the cloud.

We cover your ass, you can focus on your own stuff

http://www.clever-cloud.com

PAAS PROVIDER

Page 4: How to scale your app and win the cloud challenge

WHEN YOU NEED TO SCALE

THERE ARE 2 WAYS

Page 5: How to scale your app and win the cloud challenge

GROWING AND GROWING UNTIL YOU EXPLODE OR BECOME WEIRD

Page 6: How to scale your app and win the cloud challenge

OR SPLIT THE WORK AND MAKE YOUR SOFTWARE WORK AS A TEAM

Page 7: How to scale your app and win the cloud challenge

Build an army of fat app

YOU CAN DO BOTH

Page 8: How to scale your app and win the cloud challenge

SO WE NEED TO BE ABLE TO DISPATCH THE WORK

SCALE OUT

• Many workers doing the same thing

• No SPOF

• Growing is more easy

• Introduce best practice

SCALE UP

• 1 Fat instance

• 1 Fat application

• SPOF (single point of failure)

• Hard to maintain

• Always has a limit

• Short term meaning

BEST LONG

TERM

SOLUTION

Page 9: How to scale your app and win the cloud challenge

SO, HOW TO SCALE OUT ?JUST SOME FACTS

Page 10: How to scale your app and win the cloud challenge

SPLIT PROCESS AND STORAGE

Storage• Databases• Files• Sessions• Events• …

Code• Can be replicated• Stateless• Process

Page 11: How to scale your app and win the cloud challenge

Picking one instance or another doesn’t matter

STATELESSNESS IS THE KEY

Page 12: How to scale your app and win the cloud challenge

CONSIDER MORE THINGS AS DATA• User account

• Users data

• Files

• Sessions

• Events

Page 13: How to scale your app and win the cloud challenge

CHOOSE DATASTORE WISELYYOU CAN SHOULD USE MANY DATASTORES

Page 14: How to scale your app and win the cloud challenge

DATASTORE CHOICES ARE DRIVEN BY USAGE

Make decisions based on

needs

Do I need atomicity of requests ?

Do I need concurrent access ?

Do I mostly read or write ?

Do I need relational ?

Do I need big storage capacity ?

Do I need high

availability ?

Page 15: How to scale your app and win the cloud challenge

• Not a big volume

• DB have to manage data TTL

• Data model : K/V

• Multiple writes at the same time

• High availability

I need to store sessions

QUICK EXAMPLE

Page 16: How to scale your app and win the cloud challenge

• Not a big volume It’s OK, PG can handle small quantity of data

• DB have to manage data TTL

No, I have to do it manually

• Data model : K/VNo, PG is relational (mainly)

• Multiple writes at the same time

No, PG is Atomic

• High availability

PG is awesome ;-) Use of PG bouncer or similar allow good clustering

I need to store sessions

QUICK EXAMPLE

Page 17: How to scale your app and win the cloud challenge

• Not a big volume It’s OK, redis can handle small quantity of data

• DB have to manage data TTL

Yes Redis can do it

• Data model : K/V Yes

• Multiple writes at the same time

No, redis is pseudo Atomic (master/slave)

• High availabilityRedis is great, but cauterization is rude…

I need to store sessions

QUICK EXAMPLE

Page 18: How to scale your app and win the cloud challenge

• Not a big volume It’s OK, CB can handle small quantity of data

• DB have to manage data TTL

Yes CB can do it

• Data model : K/V Yes

• Multiple writes at the same time

OK, this is possible with memcached protocol

• High availabilityClustering is built in, no downtime

I need to store sessions

QUICK EXAMPLE

Page 19: How to scale your app and win the cloud challenge

USE ONLINE DATABASE / BE READY TO TEST IN JUST A FEW MINUTES NO NEED TO TRASH YOUR COMPUTER

Page 20: How to scale your app and win the cloud challenge

DON’T BE THAT GUY

Page 21: How to scale your app and win the cloud challenge

DO NOT USE A TECHNOLOGY BECAUSE YOU <3 IT OR BECAUSE IT’S HYPE : USE IT BECAUSE IT FITS YOUR NEEDS

BALANCE YOUR LEARNING CURVE WITH THE TIME SAVED

Page 22: How to scale your app and win the cloud challenge

DO NOT CREATE MONSTERS

Page 23: How to scale your app and win the cloud challenge

COMMON MISTAKES

Page 24: How to scale your app and win the cloud challenge

DO NOT USE MEMORY AS DATABASELIKE : SHARED / GLOBAL VARIABLE, CACHE “IN THE CODE”, INTENSIVE SESSION USAGE…

Page 25: How to scale your app and win the cloud challenge
Page 26: How to scale your app and win the cloud challenge

DO NOT USE A VARIABLE FOR MORE THAN ONE REQUEST

Page 27: How to scale your app and win the cloud challenge

2 + 2 = 4

FOR SAME INPUT, SAME OUTPUT

Page 28: How to scale your app and win the cloud challenge

GET do not change data on server

BE HTTP CONSISTENT

Page 29: How to scale your app and win the cloud challenge

And data will be lost

CODE WILL FAIL

Page 30: How to scale your app and win the cloud challenge

DO NOT USE FILE SYSTEM AS DATASTORE

File system are POSIX compliant

• POSIX is ACID• POSIX is powerful but is bottleneck • File System is nightmare of ops • File System is create coupling (host provider/OS/language)• Free SPOF multi tenant File System is a unicorn

STORE IN DATABASE, OR DATASTORE LIKE S3 (AWS) DEDICATED TO FILE MANAGEMENT

Page 31: How to scale your app and win the cloud challenge

CAREFUL USE OF DARK MAGIC

Page 32: How to scale your app and win the cloud challenge

SPLIT THE CODE : MODULES

• Smallest code base

• Deploy as service for each other

• Focus on best technology for a problem

Page 33: How to scale your app and win the cloud challenge

SCALE YOUR TEAMMODULARIZE YOUR TEAM

Page 34: How to scale your app and win the cloud challenge

USE EVENT BROKER TO MODULARIZE YOUR APP• AMQP

• Celery

• 0MQ

• Redis

• JMS

• Some case : hadoop, akka…

• …

CRON is not an event queue

Page 35: How to scale your app and win the cloud challenge

MAKE HARD COMPUTATION ASYNC

Page 36: How to scale your app and win the cloud challenge

ALWAYS USE A REVERSE PROXY

Y U NOT USE ONE ?

Page 37: How to scale your app and win the cloud challenge

DO NOT BUILD “THE SERVER” WITH NO DOC

Page 38: How to scale your app and win the cloud challenge

USE PROCESS DEPLOYMENT

Page 39: How to scale your app and win the cloud challenge

EASY MOVING OR INCIDENT MANAGEMENT

Page 40: How to scale your app and win the cloud challenge

KEEP CALM UNDER FIRE

Page 41: How to scale your app and win the cloud challenge

TRACK BUG & GET METRICS

Page 42: How to scale your app and win the cloud challenge

Quentin ADAM

Twitter : @waxzce

THX FOR LISTENING & QUESTIONS TIME