 about to the Air Force track. Her next speaker is VKC. And she works as a dream host of full staff for a press developer. And she helps make the internet better for a few months. She's passionate about code and open source technology, open data, and mindful development practices. She's a co-founder of Les Watch TV, the greatest debate of queer characters and shows. She develops software and trials queer representation, and she's a co-founder to make the data visible. Without further ado, we got it. Hi, I'm Davey. We're coming to the non-beauty bird talk. The other room is hackballed wall. Today I'd like to talk to you about the curious case of a comatose cloud. In the work of computer programming, there are two separate but distinct parts of you. One is that the cloud is magical and perfect. The other is that it's just a fancy name for server somebody else owns. The following is a true story of performance enhancements gained by using the cloud. No names have been changed to protect the innocent. I came to this wonderful month of October last year where I have cycles slow. It's kind of never humanly possible. I like to go to the font icons, and I love font icons. But resize. They can be colored. They can be transformed. And they're relatively small size, so your site's going to run quickly instead of the VF, or instead of those nice little pixelated images we used to do back in the 90s, and yes, I've been doing websites for that long. I've said a hundred icons that I happen to use on less-watched TV. We don't use all 700 at any one point. All sizes, small, the entire library, for example, is less than two megs. But each individual image is for the site. I thought, hey, you know what's perfect for this? It's going to be the cloud, right? The other reason I decided to put them on the cloud was I thought, okay, we're using this library on six different servers for six different sites we happen to be running. Three are related to less-watched TV, three are not. I don't want to copy them out every time I add an image or remove an image or a repository. Save myself some time. I'm not going to explain how you upload images to the cloud. I'm going to assume that you're all intelligent people who Google how do I upload images to whatever my cloud is. It was really that simple. I just used my SF2 key client and off I went. You ever tried to upload one to WordPress? You might have noticed you can't. The client type is blocked. This is because SVG is a document. Like that, what I mean is that while most of us use those images, they can be, you can open it up. You can edit it like a document you don't need a visual. I don't recommend you actually do that unless you know what you're doing. I have made images that look like they were drawn by me and I am not a graphic artist. I just work by giving you access to the DOM, which is the document object model. The fancy term, most of us who use the internet go for a minute, wait a second. What's going on with the DOM? Well, it limits the amount of power that you have or you can't on another server. It restricts how much you can do with an image. I had to prevent it from hurting my users. So by limiting things we've got a DOM model separates things. The way to get around this and to let your browser, your CSS edit an image that's on another site is by embedding your SVG content into a file. So with the regular image when you put an image tag top it and it off you go. You can't apply CSS anymore. You can't color it. You can't study, you can't do all those wonderful things I want to do using WordPress. You do that with the HTTP API. Just command, I'll WP remote it yet. It goes in it. You have a bunch of different parameters that you can pass through and once you've got the file you can say I want the body. I want the file name. I was trying to explain why I did this. Why don't you use file-get-contents that's in PHP. Because that's actually blocked on a lot of web-hosts. You don't want to be able to do a file-get-content from every server. In fact, I would like to want people to do a file-get-content from every server because I work for a web-host and I know firsthand people don't actually know what they're getting. If they use WP remote yet it's going to be a lot easier. Plus, using the HTTP API is actually more reliable. This is going to run on any site that can run WordPress because it's got fallbacks. It does all that extra logic that you don't want to have to think about. I would like to get the image and it reaches out and it gets. What if you can check did I get the image? Great, that's what I want to do. I'm going to reach out, grab my SDG and get the content off my go-to-the-races. Now, again, you could still be smiling at contents for this on some server but once you've already done that remote yet you can just hang on to it, check the error window pop on to it, grab all of that. It takes about a second. Not even really. I'm going to test server and that has something horrible. I've heard of this TV show called the L Word and it's about lesbians and a lot of lesbian characters on that show. And I have a page that was trying to enumerate all of them. That's 65 of them at this point in time that have names and lines. That's a lot of characters and 13.5 seconds to load on our test server. That's not acceptable. Nobody's going to sit and wait around on a page like that to load. And I said, oh, we have a problem. I turned to Tracy, the woman I work with who makes the site. I said, your design is great. I've done something horrible. I had five days because we didn't breathe. That was our cutoff day. Five days of absolutely debugging nightmares. My first step was, okay, what actually is going on here? To start by looking where I thought it was. So I started checking the number of other panel lists of which ones took the longest to load and I started understanding what was going on in general to help make these judgment calls. I knew what the content was on my site. I was aware of what I was building. I was aware of how much data was going to be on each page. I said, all right, let's load a page that has two characters. I mean, that one loads all right pretty fast. Let's load a page that has three characters. Let's load this other page to get over it. And then we're back to 13 seconds. It was what led me towards where I was understanding that the problem was I had a list of custom post types on another custom post page. 2,000 SOA characters I've got. 900 SOA TV shows. Each TV show calls a list of the number of characters of each of which have their own custom post type. Cross-referential data. I've got it that slow. I've got my panel wrong somewhere. Just to make sure that I'm not crazy. OK, to the one with the most back and forth data base calls. Here we go. 13 seconds because I was counting the exact way to figure out what's wrong with your site. And it showed me slow database queries. It was great. I could read through the number of TV calls. They just updated it yesterday, by the way, or two days ago, and it has a beautiful new interface. I love it so much. It looks like I'm just using an inspector on Chrome, on Safari, it blends in perfectly. And it's understandable. It's presented in a way that even someone who's brand new could look at it and go, oh, this thing that's in bright red that says really slow is probably really slow. And that's what you need, because you're looking at so many different aspects of your site while you're trying to debug it. Having something point out, just so you know this database query is really bad and it's really slow. So what do I do? I optimize my database. I run WPDB optimize because I love WP CLI. There are other ways you can do this. Just Google optimizing your database. I threw in some options. Which is something I don't often recommend someone even consider on their WordPress site. But I happen to have database caching on the server of my desktop site. Let's see if that's related. I try to do all of those things that you always do with slow databases. To try to speed it up, I drop down how many of my drafts I was saving and turned it off entirely. I made sure that the database was nice and clean. I cleaned out all the plumbing on windows that came by the way. The way that I'm calling SQL that's making this really slow. Because I'm searching through 2,000 to 3,000 characters and I'm only getting about 60-ish back that I need. Maybe I should change how I'm doing the loop because all the characters give me a counter that has wonderful tools that you can say how many things you're looking for. But what it really says is how many things do I want to get back to smaller so that I'm expecting a smaller result. If I know the average number of characters on a show, I can look for that number plus standard. If a little bit of math, my father's mathematician can be so proud of it, figure out averages, come out and put that in. See if that gets in the game. If I run as fast as humanly possible, it wasn't helping. Okay, it's got to be the number of times I'm doing the calls. Because we're trying to list all the characters or recurring characters and guesses. Clearly, that's why that L word is slow. They've got so many of all of those. Most shows have two or three regulars, five or six recurring, and the media doesn't guess. And the L word has about 25 each. It's a very special show. It's a great one to use for this. Okay, so for each group, we said let's see this post-ID and meta and let's optimize our query a little bit faster. That wasn't it at all. In fact, those database calls turned out to be incredibly fast. They weren't even marked as yellow on group. Also, it's because I was using database catching, object catching on the back end. And on top of that, I was telling WordPress to make the kind of queries and searches that WordPress was good at. I was giving it a small amount of data. I was limiting what it was looking for. And I had a fast data because that's what we were supposed to do. So maybe it was running in a row two of the times I'm searching. Let's just get the regular characters. It was still just a slow. I got my bicycle and went home. It lets me kind of reset my brain and stop looking at a screen and then just yell at cars so you can understand how to ride on bicycles. So when I got here, I wrote the query code and I got home. Instead of looking for as many possible posts, I did the limits. I wrote as many as possible. I used cache data. I made sure it query things in the most optimal way possible and it wasn't the volume. I went to the statistics page and I went to the show listing page. They weren't actually that slow. Or the statistics page wasn't. The show listing page got really, really slow. But wait a second. That's just giving me an archive of all the posts and the specific custom posts.