Scaling on DigitalOcean

1,050 views

Published on

A quick slidedeck for the local WordPress meetup around scaling web applications on DigitalOcean.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,050
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Scaling on DigitalOcean

  1. 1. DAVID WORTHDATE PRESENTER: 06.16.15 TITLES ARE HARD EVEN WHEN YOU SCALE WEB APPLICATIONS WELL
  2. 2. Intros - All Around David Worth (dworth@digitalocean.com) Friendly Engineer at DigitalOcean (seriously, seem my business cards) Who are you nice folks?
  3. 3. What is DigitalOcean? We provide "Droplets" e.g. Virtual Private Servers, Backups, Private Networking, IPv6, DNS, and amazing tutorials and support. We also provide a high-quality RESTful API which provides access to everything you see in the web UI "cloud". DigitalOcean is a “Cloud Provider” e.g.
  4. 4. And… We’re Hiring Come work with me! - Careers at DigitalOcean
  5. 5. DROPLETS COME IN NUMEROUS SIZES “SIZE” DICTATES CPU, RAM, DISK SIZE, AND BANDWIDTH
  6. 6. WITH ALL THE DISTRIBUTIONS (AND FREEBSD!!)
  7. 7. AND IN FAR-FLUNG AWESOME REGIONS OF THE WORLD TUNE FOR YOUR TARGET AUDIENCE!
  8. 8. AND OUR “ONE-CLICK” APPLICATIONS
  9. 9. AT LEAST ONE OF WHICH MIGHT BE OF INTEREST!
  10. 10. INTERMISSION WHEREIN DROPLETS WERE CREATED AND VERY LITTLE DEMO-FAIL WAS COMMITTED!!
  11. 11. SCALING WHY AND HOW?
  12. 12. THE VIRAL SELFIE A CONTRIVED EXAMPLE OF NEED.
  13. 13. When first starting a new blog, site, application, or toy it probably makes sense to use the smallest server you can get away with for money reasons.
  14. 14. … But then you take a great selfie and …
  15. 15. SO YOU’VE DECIDED TO BECOME INTERNET FAMOUS
  16. 16. … and now your site can’t handle the load!
  17. 17. NOW I NEED TO DO SOMETHING! … HAVE YOU TRIED SCALING?
  18. 18. The two types of scaling: Vertical - using bigger and bigger servers to meet your needs. Horizontal - using more and more (potentially smaller) servers to meet your needs.
  19. 19. Two types of Vertical Scaling at DigitalOcean Flexible - increase CPU and memory temporarily - this can always be un-done and can meet a temporary need. Permanent - increase all of the attributes of your Droplet (CPU, RAM, disk, and bandwidth) - cannot be undone. Both are performed by “resizing” your Droplet.
  20. 20. Sounds Great! What do I need to know? Resizing requires your Droplet to be powered down, then resized, and then powered back up. e.g You will have an outage in case of a resize! e.g. Your internet famousness will falter! (NO!!!)
  21. 21. So when would I want to resize? Before you launch! Doing your development of a new site on the smallest possible instance is cost-effective and makes sense. But before you post your site to /r/ cuteness resize!
  22. 22. Vertical Scaling! * Yes - bigger pixels are faster/better/MOAR in this diagram
  23. 23. BUT TALL THINGS SOMETIMES TOPPLE…
  24. 24. Why Horizontal Scaling? Because sometimes bad things happen to good droplets - Servers Crash. Software bugs bring down a server. The internet just breaks. We try to stop it but… More importantly - Composing a few smaller servers can be used, and more can be added without downtime!
  25. 25. WHERE WE START!
  26. 26. … Remember how we got internet famous?
  27. 27. … But we can’t afford downtime with a resize…
  28. 28. … Perhaps a new strategy? Like MOAR servers?
  29. 29. THE FIRST “EASY” STEP LOAD-BALANCING OUR WEB SERVERS
  30. 30. The short-version… Several “smaller” webservers - all sharing a single database server - are “balanced” by a reverse- proxy server such as Nginx or HAProxy. Greater cost and technical overhead but greater resiliency under failure of a single web-serving droplet. You can add more webservers anytime you like! As many as you like really. And of any size!
  31. 31. Oh… but what about that lone Database server! What happens if it crashes? Or is overwhelmed by a complicated query?
  32. 32. Maybe we can scale it horizontally too?
  33. 33. THE NEXT-STEP REPLICATING OUR DATABASE SERVERS FOR GREATER RESILIENCY - HYPERDB
  34. 34. Database Replication The data on most applications and sites is write-once / read-many so… We can create replicas of the database holding all of your precious content and have it arrive on other database servers automagically. Each webserver can then query its own copy of the data. In the WordPress world this can be achieved with HyperDB.
  35. 35. … but what about static assets (like my selfies?!)
  36. 36. THERE’S A NETWORKED FILESYSTEM FOR THAT!
  37. 37. ADDING A CDN OR NETWORKED FILESYSTEM TO REPLICATE ASSETS
  38. 38. … that “or” If you have constraints on your assets that you control them at all times use a Network Filesystem like Ceph or GlusterFS. If you don’t have that constraint CDNs provide many advantages including lower infrastructure complexity, lower-latency, and a specialized services whose only job is to server your assets.
  39. 39. TIPS AND TRICKS TO MAKE YOUR LIFE EASIER
  40. 40. Use some Configuration Management When bringing up new servers, it really helps to not have to spend any manual energy doing so - Use DigitalOcean’s User-Data, Ansible, Puppet, SaltStack, or Chef. This ensures your life is easier at 4am after three consecutive all-nighters when you need more capacity.
  41. 41. You can use vertical scaling with horizontal scaling Once you can add and remove servers to your configuration, you can add various sizes too! To scale up your entire architecture spin up a new, larger server, and spin down a smaller one. Your Load Balancer will add and remove them as appropriate. Do this until all of your servers are upgraded!
  42. 42. SUCCESS!! SCALE!!
  43. 43. Questions?
  44. 44. References: How to Automate the Scaling of your web application on DigitalOcean Automating the Deployment of a Scalable WordPress Site How to Optimize WordPress Performance with MySQL Replication on Ubuntu 14.04 Automating App Deployments using User-Data

×