45
DAVID WORTH DATE PRESENTER: 06.16.15 TITLES ARE HARD EVEN WHEN YOU SCALE WEB APPLICATIONS WELL

Scaling on DigitalOcean

Embed Size (px)

Citation preview

DAVID WORTHDATE PRESENTER:06.16.15

TITLES ARE HARDEVEN WHEN YOU SCALE WEB APPLICATIONS WELL

Intros - All Around

David Worth ([email protected])

Friendly Engineer at DigitalOcean (seriously, seem my business cards)

Who are you nice folks?

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.

And… We’re Hiring

Come work with me! - Careers at DigitalOcean

DROPLETS COME IN NUMEROUS SIZES“SIZE” DICTATES CPU, RAM, DISK SIZE, AND BANDWIDTH

WITH ALL THE DISTRIBUTIONS (AND FREEBSD!!)

AND IN FAR-FLUNG AWESOME REGIONS OF THE WORLDTUNE FOR YOUR TARGET AUDIENCE!

AND OUR “ONE-CLICK” APPLICATIONS

AT LEAST ONE OF WHICH MIGHT BE OF INTEREST!

INTERMISSIONWHEREIN DROPLETS WERE CREATED AND VERY LITTLE DEMO-FAIL WAS COMMITTED!!

SCALINGWHY AND HOW?

THE VIRAL SELFIEA CONTRIVED EXAMPLE OF NEED.

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.

… But then you take a great selfie and …

SO YOU’VE DECIDED TO BECOME INTERNET FAMOUS

… and now your site can’t handle the load!

NOW I NEED TO DO SOMETHING!… HAVE YOU TRIED SCALING?

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.

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.

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!!!)

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!

Vertical Scaling!

* Yes - bigger pixels are faster/better/MOAR in this diagram

BUT TALL THINGS SOMETIMES TOPPLE…

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!

WHERE WE START!

… Remember how we got internet famous?

… But we can’t afford downtime with a resize…

… Perhaps a new strategy? Like MOAR servers?

THE FIRST “EASY” STEPLOAD-BALANCING OUR WEB SERVERS

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!

Oh… but what about that lone Database server!

What happens if it crashes? Or is overwhelmed by a complicated query?

Maybe we can scale it horizontally too?

THE NEXT-STEPREPLICATING OUR DATABASE SERVERS FOR GREATER RESILIENCY - HYPERDB

Database ReplicationThe 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.

… but what about static assets (like my selfies?!)

THERE’S A NETWORKED FILESYSTEM FOR THAT!

ADDING A CDN OR NETWORKED FILESYSTEM TO REPLICATE ASSETS

… 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.

TIPS AND TRICKS TO MAKE YOUR LIFE EASIER

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.

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!

SUCCESS!!SCALE!!

Questions?