some advice from the guy who handle your applications uptime - scalaio 2013

41
HOW TO SCALE YOUR APP SOME ADVICE FROM THE GUY WHO HANDLES YOUR APP UPTIME QUENTIN ADAM AT SCALA.IO @ WAXZCE 2013

Upload: quentin-adam

Post on 08-May-2015

547 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Some advice from the guy who handle your applications uptime - scalaIO 2013

HOW TO SCALE YOUR APP SOME ADVICE FROM THE GUY WHO HANDLES YOUR APP UPTIME

QUENTIN ADAM AT SCALA.IO

@WAXZCE2013

Page 2: Some advice from the guy who handle your applications uptime - scalaIO 2013

MY DAY TO DAY WORK : CLEVER CLOUD, MAKE YOUR APP RUN ALL THE TIME

Page 3: Some advice from the guy who handle your applications uptime - scalaIO 2013

WHEN YOU NEED TO SCALE

THERE ARE 2 WAYS

Page 4: Some advice from the guy who handle your applications uptime - scalaIO 2013

GROWING AND GROWING UNTIL YOU EXPLODE OR BECOME WEIRD

Page 5: Some advice from the guy who handle your applications uptime - scalaIO 2013

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

Page 6: Some advice from the guy who handle your applications uptime - scalaIO 2013

Build an army of fat app

YOU CAN DO BOTH

Page 7: Some advice from the guy who handle your applications uptime - scalaIO 2013

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 8: Some advice from the guy who handle your applications uptime - scalaIO 2013

SO, HOW TO SCALE OUT ?JUST SOME FACTS

Page 9: Some advice from the guy who handle your applications uptime - scalaIO 2013

SPLIT PROCESS AND STORAGE

Storage• Databases• Files• Sessions• Events• …

Code• Can be replicated• Stateless• Process

Page 10: Some advice from the guy who handle your applications uptime - scalaIO 2013

Picking one instance or another doesn’t matter

STATELESSNESS IS THE KEY

Page 11: Some advice from the guy who handle your applications uptime - scalaIO 2013

CONSIDER MORE THINGS AS DATA• User account

• Users data

• Files

• Sessions

• Events

Page 12: Some advice from the guy who handle your applications uptime - scalaIO 2013

TRUST YOUR MIDDLEWARE

Page 13: Some advice from the guy who handle your applications uptime - scalaIO 2013

USE AN EVENT BROKER TO MODULARIZE YOUR APP

• AMQP

• Celery

• 0MQ

• Redis

• JMS

• Even some http chunk or websocket

• Some case : hadoop, akka…

• …

Page 14: Some advice from the guy who handle your applications uptime - scalaIO 2013

CRON + FS IS NEITHER AN EVENT QUEUE NOR A JOB SCHEDULER

Page 15: Some advice from the guy who handle your applications uptime - scalaIO 2013

CHOOSE YOUR DATASTORE WISELYYOU CAN SHOULD USE MANY DATASTORES

Page 16: Some advice from the guy who handle your applications uptime - scalaIO 2013

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 17: Some advice from the guy who handle your applications uptime - scalaIO 2013

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

Page 18: Some advice from the guy who handle your applications uptime - scalaIO 2013

COMMON MISTAKES

Page 19: Some advice from the guy who handle your applications uptime - scalaIO 2013

DO NOT USE THE FILE SYSTEM AS A DATASTORE

File system are POSIX compliant

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

STORE IN DATABASE, OR IN A DATASTORE LIKE S3/RIAKCS DEDICATED TO FILE MANAGEMENT

Page 20: Some advice from the guy who handle your applications uptime - scalaIO 2013

LOGS IN FILES I HATE IT

Page 21: Some advice from the guy who handle your applications uptime - scalaIO 2013

USE STREAMING I/O TO STREAM DATA DIRECTLY TO DATABASE

HTTP Post dataTemporarily store as file

or in memory

Store it into your storage

backend

Say OK to client

Page 22: Some advice from the guy who handle your applications uptime - scalaIO 2013

USE STREAMING I/O TO STREAM DATA DIRECTLY TO DATABASE

HTTP Post data

Directly stream your data to

Storage backend

Say OK to client

Page 23: Some advice from the guy who handle your applications uptime - scalaIO 2013

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

Page 24: Some advice from the guy who handle your applications uptime - scalaIO 2013

DO NOT USE A VARIABLE FOR MORE THAN ONE REQUEST

Page 25: Some advice from the guy who handle your applications uptime - scalaIO 2013

F(X) = X * 2F(2) = 4^ WE ASSUME THATFOR SAME INPUT, SAME OUTPUT

Page 26: Some advice from the guy who handle your applications uptime - scalaIO 2013

You have to understand that : you’re functional programing addicts ;-)

IT’S LIKE MATH FUNCTION

Page 27: Some advice from the guy who handle your applications uptime - scalaIO 2013

Example : GET should not change data on server

RESPECT HTTP

Page 28: Some advice from the guy who handle your applications uptime - scalaIO 2013

data will be lost

CODE WILL FAIL

Page 29: Some advice from the guy who handle your applications uptime - scalaIO 2013

CAREFUL USE OF DARK MAGIC

Page 30: Some advice from the guy who handle your applications uptime - scalaIO 2013

DO NOT CREATE MONSTERS

Page 31: Some advice from the guy who handle your applications uptime - scalaIO 2013

MAKE HARD COMPUTATION ASYNC

Page 32: Some advice from the guy who handle your applications uptime - scalaIO 2013

SPLIT THE CODE : MODULES

• Smallest code base

• Deploy as service for each other

• Focus on best technology for a problem

Page 33: Some advice from the guy who handle your applications uptime - scalaIO 2013

SCALE YOUR TEAMMODULARIZE YOUR TEAM

Page 34: Some advice from the guy who handle your applications uptime - scalaIO 2013

ALWAYS USE A REVERSE PROXY

Y U NO USE ONE ?

Page 35: Some advice from the guy who handle your applications uptime - scalaIO 2013

DO NOT BUILD “THE SERVER” WITH NO DOC

Page 36: Some advice from the guy who handle your applications uptime - scalaIO 2013

USE PROCESS DEPLOYMENT

Page 37: Some advice from the guy who handle your applications uptime - scalaIO 2013

THE GOOD WAY OF DEPLOY AN APP :

git push

Page 38: Some advice from the guy who handle your applications uptime - scalaIO 2013

EASY MOVING OR INCIDENT MANAGEMENT

Page 39: Some advice from the guy who handle your applications uptime - scalaIO 2013

KEEP CALM UNDER FIRE

Page 40: Some advice from the guy who handle your applications uptime - scalaIO 2013

TRACK BUG & GET METRICS

Page 41: Some advice from the guy who handle your applications uptime - scalaIO 2013

I’m @waxzce on twitter

I’m the CEO of

a non exclusive scala PaaS provider, give it a try ;-)

THX FOR LISTENING & QUESTIONS TIME

sponsors