building scalable web apps - lvl.up kl

18
Building Scalable Web Apps http://www.shaolintiger.com @ShaolinTiger on Twitter

Upload: gareth-davies

Post on 25-Jan-2015

5.290 views

Category:

Internet


0 download

DESCRIPTION

This is my talk from the July LVL.UP KL meeting (formerly WebCamp KL) held on August 6th at Mindvalley, Bangsar. The talk covers a basic introduction to scalability, 5 things to consider/think about and 5 things you can do build at scale. WebCampKL Group is here - https://www.facebook.com/groups/webcamp/ The video of this talk is available here: http://youtu.be/Djs-8lGpz_U (also added as the 19th slide).

TRANSCRIPT

Page 1: Building Scalable Web Apps - LVL.UP KL

Building Scalable Web Apps

http://www.shaolintiger.com @ShaolinTiger on Twitter

Page 2: Building Scalable Web Apps - LVL.UP KL

So who am I? Mindvalley CTO etc.

- Also Sys Admin- DevOps Guy- Technical Architect

Page 3: Building Scalable Web Apps - LVL.UP KL

Pulse Check

- Familiar with at least 1 of these technologies?- Setup/used one of these technologies?- Could debate the pros of nginx over Apache?

Page 4: Building Scalable Web Apps - LVL.UP KL

This Talk

- Intro to scaling- 5 Points to consider- 5 Things you can do

Page 5: Building Scalable Web Apps - LVL.UP KL

Scalability vs Performance

- Scalability can bring performance, but not vice-versa

“Performance measures the speed with which a single request can be

executed, while scalability measures the ability of a request to maintain its

performance under increasing load.” – Steven Haines

Page 6: Building Scalable Web Apps - LVL.UP KL

Understand ScalingScaling up (Vertical)

Scaling out (Horizontal)

Page 7: Building Scalable Web Apps - LVL.UP KL

Scaling up vs Scaling upScaling up- Can become very costly- Single point of failure (SPOF)- Less complex to manage- Has a Finite limit

Scaling out- Cheaper now with cloud/vms/commodity h/w- Increases availability- Management can become very complex- Deployment can become slow

Page 8: Building Scalable Web Apps - LVL.UP KL

Points to consider 1) Logging

- Logging can get OUT OF CONTROL- Use a centralized log management system- Check out Loggly or Papertrail (we use this)

Page 9: Building Scalable Web Apps - LVL.UP KL

Points to consider 2) User Sessions

- Centralize your user sessions- Use a fast in memory store- Remember to invalidate/clear cache- Check out Redis (or just use Memcache if you already have it as part of your architecture)

Page 10: Building Scalable Web Apps - LVL.UP KL

Points to consider 3) Monitoring

- Monitor EVERYTHING

- Make data driven decisions

- Check out Munin (my favourite)

Page 11: Building Scalable Web Apps - LVL.UP KL

Points to consider 4) Bottlenecks

- Usually the database/datastore

- Can also possibly be the filesystem (caused by logging, heavy static file delivery etc)

- Also possible to saturate network bandwidth

Page 12: Building Scalable Web Apps - LVL.UP KL

Points to consider 5) Traffic Profile

- Spiky traffic is a lot harder to deal with than linear growth (you have to build differently)- Even tools that ‘autoscale’ take time

Page 13: Building Scalable Web Apps - LVL.UP KL

Things you can do 1) CACHE!

- You should really by trying to cache everything you can:- - Objects

- - User Sessions

- - API Requests

- - Page Cache

- - Partials Caching (In Rails)

Page 14: Building Scalable Web Apps - LVL.UP KL

Things you can do 2) Understand

- Know your tools/stack (or hire someone who does)

- AKA MySQL query_cache? What’s that?

- Optimize but don’t overdo it (and not too early)

- Build for scale, but don’t get complex without reason

Page 15: Building Scalable Web Apps - LVL.UP KL

Things you can do 3) Use Queues

- There are great tools out there for this (RabbitMQ etc)

- Makes it much less necessary to scale your database

- Takes the burden of spiky loads without downtime

Page 16: Building Scalable Web Apps - LVL.UP KL

Things you can do 4) Ditch Search

- This is what happens when you do a full text search on a database not designed for it.

- Use a specialised data store for search:- Solr- Lucene- Elasticsearch

Page 17: Building Scalable Web Apps - LVL.UP KL

Things you can do 5) Leverage

- Use a CDN (Like OnApp, CloudFront, Edgecast etc)- If you can use a specialist host (WPengine/Page.ly)- Utilise a specialist DNS host (Route 53/UltraDNS)- Profile your app with NewRelic

Page 18: Building Scalable Web Apps - LVL.UP KL

The END!

No Questions!

Stalk me @ShaolinTiger

This preso will be on http://slideshare.net/shaolintiger