Archived video

This video is archived and won't be updated. We're keeping it online for now as a courtesy.

Alternate resources: 

Optimize Your Site for the Cloud

Video loading...

  • 0:00
    Manage Drupal Sites with Pantheon Optimize Your Site for the Cloud Addison Berry
  • 0:09
    So let's talk a little bit about what it means
  • 0:12
    to have your site and your environment on Pantheon in the Cloud.
  • 0:16
    And what does that mean? What are the implications of that for you?
  • 0:21
    So in this lesson, we're going to take a look at the balance between high performance and availability,
  • 0:26
    and we're going to compare different kinds of server architecture
  • 0:30
    and understand where Pantheon's server architecture fits into that picture.
  • 0:34
    And then we're going to review some tools and techniques
  • 0:37
    for optimizing your site for living in the architecture
  • 0:41
    that Pantheon's providing for you.
  • 0:45
    So just to set some context here,
  • 0:47
    as a platform, Pantheon needs to balance the tradeoffs
  • 0:51
    between high performance and high availability.
  • 0:54
    So while it's important to reduce your single point of failure
  • 0:57
    and make sure that you can scale very quickly and that kind of a thing,
  • 1:00
    the downside is that as you add those features,
  • 1:05
    you will introduce complexity and latency to the solution.
  • 1:10
    And so you need to end up balancing those things and figuring out what the best way forward is.
  • 1:14
    So let's talk about that.
  • 1:17
    Let's compare a couple of different architectures here.
  • 1:20
    So we have single-server stack.
  • 1:23
    The great thing about having just one server, one piece of hardware that has your entire website on it,
  • 1:28
    is that you have zero latency.
  • 1:30
    So when your Drupal site is making a database request,
  • 1:33
    it happens right there. It doesn't have to travel anywhere.
  • 1:36
    Now, of course, on the flip side, one of the big disadvantages
  • 1:40
    is that you have a single point of failure
  • 1:42
    and you don't have scalability, right?
  • 1:44
    So if my server blows up, I'm done.
  • 1:47
    There's nothing else happening there.
  • 1:49
    And that's a really risky road to go down.
  • 1:54
    Now a solution that's come to that is clustered servers or distributed servers
  • 1:58
    where you actually have lots of different servers and you kind of balance that.
  • 2:02
    We have load balancers that say which servers are going to do what.
  • 2:05
    You have database replication, backups,
  • 2:08
    Network File Systems, lots of things to kind of spread things out a little bit more.
  • 2:12
    But once you start to do that, you get some latency
  • 2:15
    because now that database request is going to go from your Drupal site,
  • 2:19
    whatever server that's on, over to the database server and grab that
  • 2:22
    and then go get that file, bring that back.
  • 2:24
    So you are introducing some travel time
  • 2:28
    into the process of delivering your website.
  • 2:31
    The other thing about this solution is it's pretty expensive
  • 2:33
    to maintain a whole lot of actual servers,
  • 2:36
    and you end up scaling by adding new servers, adding a whole new piece of hardware.
  • 2:40
    Again, very expensive, time-consuming,
  • 2:43
    can be disruptive to your site, those kinds of things.
  • 2:47
    Now Pantheon has taken this distributed architecture stuff
  • 2:52
    a step further and has brought it up into the Cloud.
  • 2:56
    And they are using application containers
  • 3:00
    to actually run the sites
  • 3:03
    and you have cloud-based file systems and things like that.
  • 3:05
    This provides superfast scaling
  • 3:08
    because you're using software to scale, not hardware.
  • 3:13
    You still have higher latency than a single server though.
  • 3:17
    It's fast, but it's still going to take a little bit of travel time for things to happen.
  • 3:22
    That's just the nature of the beast.
  • 3:25
    So in order to get the advantages that you want
  • 3:28
    out of using something like Pantheon's architecture
  • 3:32
    with really super fast scaling and no single point of failure and all of these things,
  • 3:36
    you need to make sure that you pay attention to that latency
  • 3:39
    and don't let it get away from you.
  • 3:43
    So this is a quick review of what we just looked at.
  • 3:46
    Single servers, can't scale them.
  • 3:48
    The traditional clustered hosting is expensive
  • 3:51
    and a little hard and risky to scale.
  • 3:53
    And the Pantheon stuff, we're really talking about high availability.
  • 3:59
    And the ability to just scale within seconds is big.
  • 4:03
    And so you can really manage a lot of things.
  • 4:06
    But as we said, there's a little bit of this latency thing.
  • 4:08
    So how do we handle latency so that we can take advantage
  • 4:11
    of the awesomeness of Pantheon in the Cloud?
  • 4:13
    When trying to address this problem— now first of all,
  • 4:16
    you may not really have much of a problem with this. Many sites do not.
  • 4:20
    But it's something for you to be aware of, and if it is something,
  • 4:23
    especially if you have a very large site with a lot of traffic,
  • 4:25
    these are the kinds of things that we're going to want to do.
  • 4:27
    Now before you get started with it, you want to identify your key workflow
  • 4:30
    so that you can focus your effort.
  • 4:32
    You may not really have the resources or the time to fix every single problem under the sun.
  • 4:37
    What are the critical things? And focus on that.
  • 4:41
    You should also figure out what is acceptable performance for your site?
  • 4:46
    Maybe you don't need to do anything.
  • 4:48
    Maybe for anonymous, it's great, and authenticate, it's not.
  • 4:50
    What levels do you need to have things at
  • 4:53
    in order to feel comfortable that your site is delivering everything that you want it to.
  • 4:59
    So Pantheon integrates the Varnish HTTP accelerator
  • 5:03
    on every single site, even the free ones.
  • 5:06
    And it's a standard tool for reducing load
  • 5:10
    on Drupal's site application and database servers.
  • 5:12
    People use this on all kinds of sites everywhere.
  • 5:15
    And it's going to make the anonymous page load super fast.
  • 5:19
    Now Varnish Cache is both pages and smaller objects,
  • 5:22
    so like JavaScript and CSS and that kind of a thing.
  • 5:25
    So you're reducing the load on the actual application itself, right?
  • 5:30
    It doesn't have to generate all that stuff all the time.
  • 5:32
    Using Varnish may mean reconfiguring how your site uses cookies
  • 5:37
    and some things like that with your cache configuration,
  • 5:39
    so it's something that you do want to just sort of understand and make sure that you configure correctly.
  • 5:44
    It's normally not a big deal. It's just something to be aware of.
  • 5:47
    And you don't have to do anything with modules in Drupal.
  • 5:50
    This is a separate layer outside of your Drupal site.
  • 5:54
    Pantheon also offers Redis which is a key-value store
  • 5:57
    for caching Drupal components.
  • 5:59
    So it gives you more benefits for authenticated users,
  • 6:04
    so because you can reduce the number of database requests
  • 6:07
    and the round trips that are required to build a page when you use Redis.
  • 6:12
    So that's sort of more on the caching back-end rather than the caching front-end.
  • 6:16
    And if you've written custom queries,
  • 6:18
    you don't need to write any code for Redis to handle that.
  • 6:21
    You can just use Drupal's cache_set cache_get.
  • 6:24
    It totally works just fine with Redis for your database caching.
  • 6:29
    This is just standard best practice on all Drupal sites.
  • 6:32
    You do need to go through— it's a manual thing, right?
  • 6:34
    You have to review everything.
  • 6:36
    Make sure, are these modules needed?
  • 6:39
    If they're not being used, get them out of there.
  • 6:41
    While the difference on a single page load might not be crazy,
  • 6:45
    the aggregate across all of your page views
  • 6:47
    can make a significant difference on your site.
  • 6:51
    You want to analyze your queries and your code.
  • 6:54
    So making sure you find heavy queries, inefficient code, and those kinds of things is an important task.
  • 7:00
    Profiling page execution using low level tools
  • 7:03
    like New Relic which is included with Pantheon
  • 7:07
    will aggregate your performance statistics
  • 7:10
    and give you a good sense of what's going on overall.
  • 7:13
    Additionally, you can use modules like Devel
  • 7:16
    which has a really nice introspection into bugging, tools specific for Drupal.
  • 7:21
    That really shows you what's happening when your Drupal page is being built and loaded.
  • 7:26
    And then also, every site stores a slow database query
  • 7:31
    and a slow PHP execution log.
  • 7:33
    So you can get into your Pantheon environment via SFTP
  • 7:39
    and look at the logs directory, where those logs are stored,
  • 7:42
    and that can help you track down where you're finding—
  • 7:45
    where are those slow database queries? What are they?
  • 7:48
    And then you can track back and correct them.
  • 7:52
    Server build time is not the only consideration.
  • 7:56
    After a response has been built by Drupal,
  • 7:58
    it still needs to be transferred and rendered in the browser.
  • 8:02
    So reducing any unnecessary markup,
  • 8:04
    aggregating and compressing JavaScript, CSS,
  • 8:08
    using things like a CDN to make sure that your static content gets served faster.
  • 8:12
    All of those things are super useful. And you can use—
  • 8:17
    there are a couple of tools listed here; there are many that are out there—
  • 8:19
    here's just a sampling of some tools
  • 8:22
    that will help you find that front-end.
  • 8:24
    Like when something's getting to the browser,
  • 8:26
    where do we have problems, and where can things be optimized?
  • 8:29
    So there's YSlow, Google PageSpeed Insights,
  • 8:32
  • 8:35
    And you can get kind of a checklist of things to fix, essentially, from those.
  • 8:41
    So in short, a lightweight site is a happy site.
  • 8:45
    By taking a few steps to optimize your site
  • 8:47
    to take advantage of this Cloud architecture that you have,
  • 8:50
    you really have a great site experience
  • 8:53
    for your customers, people who are coming to your site,
  • 8:57
    plus you get that advantage of the scalability of the architecture
  • 9:02
    you're being provided with here.
  • 9:04
    And just keep in mind there's not one silver bullet
  • 9:07
    to making your site super fast.
  • 9:10
    You have to actually investigate what's going on with your particular site,
  • 9:15
    and then you're going to need a combination of different tools and techniques
  • 9:18
    to actually figure out the best way.
  • 9:20
    And again, remember, make sure you prioritize and focus your energy
  • 9:24
    instead of trying to get every single little thing done.
  • 9:29
    So to review, Pantheon is working to balance high performance
  • 9:32
    and high availability in making sure that you're getting the best bang for your buck.
  • 9:38
    With the distributed server architecture
  • 9:40
    and then the Pantheon Cloud version of that as well
  • 9:44
    to sort of look at what the differences are
  • 9:46
    and what the advantages are.
  • 9:49
    And then we looked at a bunch of different tools and techniques for optimizing your site.
  • 9:53
    The biggest hang-up with distributed server architecture
  • 9:56
    is that you do start to introduce some latency
  • 9:59
    when you're starting to spread your processes out.
  • 10:01
    And so we looked at optimizing it; we looked at things like Varnish caching,
  • 10:06
    Redis caching for your database,
  • 10:09
    optimizing your slow queries, looking for inefficient code
  • 10:12
    with tools like New Relic, and you can use Devel.
  • 10:16
    And then finally, we also just talked about the final step.
  • 10:20
    All that back-end stuff happens, but then you actually render in the browser
  • 10:22
    and you want to make sure that you're also optimizing the front-end of your site.
  • 10:27
    So we looked at what some of those things are, and some tools that will help you track that stuff down.
  • 10:32
    So by thinking about it a little bit, just being aware of these differences
  • 10:38
    and how you can tackle them means you will get the most
  • 10:41
    out of the Pantheon architecture.

Optimize Your Site for the Cloud


In this tutorial we'll provide an overview of how to make your Pantheon sites take the best advantage of the robust infrastructure Pantheon provides. We'll discuss the balance of high performance and availability, along with a comparison of different server architectures and why Pantheon has chosen to use application containers. In that comparison we'll point out the pros and cons, and then we'll go through a checklist of the tools and techniques for optimizing your site for this architecture.

Sponsored by Pantheon

Log in or sign up to download companion files.
Additional resources: