Find What You Are Looking For, Faster!

At Drupalize.Me, we're constantly working to improve your learning experience. A few months ago, we built the highly requested series implementation, which meant that when you're watching a video, you can now see all the rest of the series listed videos on the same page. With that change, we realized that we needed to improve how you find videos and series alike, since our original design was not made for the concept of videos grouped together into a series. In our latest release, named Daffidazey, our new design displays both series and videos on the same page.

You can more easily browse through all of our content, and we added filters for both category and Drupal version so you can quickly get to what you're looking for. We also had been getting a number of complaints about the site's overall performance so we spent some time doing a thorough performance audit of the site and fixing a couple of things that we found along the way.

Making Tables and Checking Them Thrice

Our new, fancy Browse Videos page consists of three different Views, a little jQuery and taxonomy redirects. We started development by creating the View that lives at the Browse menu item. It displays all Series nodes and all Video nodes that are not in a series. Views Or helped us accomplish this. The table View includes information about the category and Drupal version, which we exposed as filters (Better Exposed Filters actually) so you can easily limit the results and target the exact content you want.

Our next step was to include all of the Videos associated with each Series. To do this, we took the node id of the Series and used that as an argument to pass to another View that displayed all of the referenced Videos. After some fancy theming, it all displayed seamlessly on the same page. So as to not clutter up the listing, our custom jQuery hides the information until you're ready to see it.

We wanted to make sure that the Series length displayed in the table for the primary View. Since we don't actually have this information in the Series content type, we created a separate View utilizing the node id argument and Views Calc to aggregate the data. A simple rewrite of the field data allowed us to display this new number.

Lastly, we configured Taxonomy Redirect so that every time a category or Drupal version was displayed, it linked to the Browse Videos page with the correct exposed filter selected.

Making pages go Vrooom!

Keeping a site running at top speed is an on-going process. Things that work great when you've got only 1 user may not be so hot when you've got 10, 100, and so on. With that in mind we're always working to improve the performance of Drupalize.Me to keep things snappy for our members.

The biggest culprit was the custom code we use to "discover" files on the Amazon S3 bucket used for hosting our video files. While it's important for the site to keep an ongoing dialog with S3 so that file lists are always up-to-date, we discovered that some of our pages were acting a bit like teenagers, hogging the line for hours gossiping and disseminating fun, but unnecessary, information. When getting a list of files from the S3 API you're limited to retrieving information about 100 resources during any given request. When you've got directories with 10k plus files in them, like we do to accomodate HLS streaming for iOS devices, that conversation can require a large number of requests. This was causing the page to halt processing while PHP made requests to S3 via cURL making the overall loading time of some pages completely unacceptable. We solved this problem by converting the code to perform the lookup only once and then store the results locally until directed to perform another lookup by an administrator. This means that it involves a little more administrator interaction when adding new videos to the site but it's a worthwhile trade off in order to ensure fast page loads.

With the new design, we also found another issue caused by a rogue call to node_load() inside of our theme's template.php file when building the browse page in order to determine if the video being shown was part of a series or not. One of the first things we look for when doing a performance audit of a site are unnecessary calls to the node_load() function. It's a quick and easy way to retrieve information about a node from the database but sometimes when all you need is one small bit, like the title of the post, it can be overkill. It works by doing things like making additional database queries, querying external APIs, or any other random PHP fun, and any other modules you've got installed on your site can jump into that fun as well, and therein lies the problem. node_load() can end up being a pretty expensive function to call with that much of a party going on every time you use it.

Related Topics: 



Add new comment