Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: High Loading Time for Home Page

Status Resolved
Add-on / Version Bloqs 3.0.9
Severity
EE Version 3.5.10

Ryan Fitton

Aug 24, 2017

Description:
We have a homepage that is composed of bloqs for displaying its content. Its contents are Grids that has store information that shows up at specific time of the day. We already had disabled the code that filters the time of the day for the display of a Grid. Once we load the page having the bloqs it load time increase as the number of Grid entries increases. Please see the provided screenshots from New Relic for the trace details.

Detailed steps to reproduce the issue:
1. Setup Bloqs
2. Setup Template with Bloqs and Grids
3. Add as many Grids on the block (in our case 17 nodes)

#1

BoldMinded (Brian)

You’re saying you have Grid fields inside of Bloqs? Can you take a screenshot of your home page entry in the CP edit page?

#2

BoldMinded (Brian)

If you need an immediate decrease in speed I would suggest adding some sort of caching to your site, such as CE Cache. Regardless of page load times, caching a site is generally a good idea.

Even if I find a way to make it faster, its going to be days or even weeks. Based on your screenshot, you have a ton of blocks added to the page, is that correct? (The screenshots will help)

#3

BoldMinded (Brian)

One more question, how many blocks do you have to choose from for the home page entry, and how many are actually on the page?

#4

Ryan Fitton

I might had explained it a complicated. But here is my better explanation with the screenshots. We have Bloqs setup which has multiple entries (https://drive.google.com/open?id=0B4AVWJ8b1ojsQzdVZGxndHpIcUU) that we display on our main layout. We have a Bloqs entry and it is named as “grid” for its main display is a grid of stores that we market or put into highlight at a given time of the day (here are its Atoms: https://drive.google.com/open?id=0B4AVWJ8b1ojsdy13Q29jbjFSbnc, https://drive.google.com/open?id=0B4AVWJ8b1ojsVU1USnBxdzJVbkU, https://drive.google.com/open?id=0B4AVWJ8b1ojseVI5aDR3dzJaQUU, https://drive.google.com/open?id=0B4AVWJ8b1ojsT2toTWhBZ1ZrbG8, https://drive.google.com/open?id=0B4AVWJ8b1ojsRXg1bTlaTkFVVUE). Now here is the Home entry (https://drive.google.com/open?id=0B4AVWJ8b1ojsVC1EYWVZWWNXOTg) under the Page channel (http://prntscr.com/gcqg68). This Home entry loads very slow about an average of 45 seconds every time. At the current setup we have 17 Grid (bloq type) added on the page that was one of our previous setup that was made live and gave the slow loading time and is now being our test topic. Basically we need as much as possible grids on the home page and they will just be shown depending on the time of day. Based on our test, the more Grids that you display the longer the page loads, out of the 17 grid items, we are displaying 2 at the moment (based on the time).

We will try to incorporate the use of CECache for now and maybe a lazy loading work around, we will give you an update but please investigate / check if you can make some adjustments or advices to improve our setup.

#5

BoldMinded (Brian)

Couple things..

1) That looks like an old version of Bloqs. You would need to upgrade.

2) It looks like you actually have a Grid field inside of a block based on this image (https://drive.google.com/file/d/0B4AVWJ8b1ojsVC1EYWVZWWNXOTg/view) I’m referring to the Visible Times atom. I’m assuming this version of Bloqs was modified or hacked, because Grid is not supported inside of Bloqs. Frankly I’m wondering how the heck that is even working, and this could be contributing to the load times. Did you get a custom build of Bloqs from Q Digital Studios or did you or another developer hack it to make Grid work inside of a block?

3) That is a LOT of blocks on a page with a lot of atoms. I looked at the Bloqs code earlier and I don’t see any clear instances of what would be slow code. It already does as little work as possible to render the blocks to the page. Honestly I’m not sure if I can make any optimizations to decrease page load time.

4) If you’re displaying blocks based on time of day, I wouldn’t recommend using Bloqs for that kind of logic. You should create separate entries for each piece of content that you want to show at certain time(s) of the day, then use some other logic, such as the custom field search parameter in the entries tag to choose what to display. Displaying content this way with Bloqs seems like the wrong way to approach this problem.

#6

Ryan Fitton

  1. Done updating the plugin. Same results in term of the loading time.

  2. The Bloqs that we are using is not modified or hacked. We just did a custom plugin and then made an extension of the grid fieldtype. And then made your plugin support our custom field as per your documentation guide: https://eebloqs.com/documentation/developers. We already did testings without the plugin and what happen is that all 17 were shown and the page loaded for almost 55 seconds and then as said when the plugin is enabled and does the filtering the loading time was reduced to 45 seconds but had shown only two bloqs.

  3. Please see our previously attached screenshot from the New Relic tracing, the huge loading time was traced on the Bloqs addon. Can you advise how we can optimize that.

  4. We don’t have the luxury of time to make some redesigns on our template / layout. It would be great if you can come up with a suggestion on how to optimize the page with the current setup.

#7

BoldMinded (Brian)

2) I’d be interested in seeing that extension if you wouldn’t mind sharing?

3) I saw the trace, but as I mentioned before I already looked at the Bloqs code and don’t see any immediate areas of improvement. Its doing only what is necessary to parse and render the content. If you have 17 blocks added to that entry and each has 10 atoms, thats 170 custom fields that need to be parsed for 1 entry, even if only 2 blocks end up needing to be output to the page b/c of the timing logic, the other 15 are fully parsed (you can see it in the trace), then I assume the plugin you’re referring to is what is determining which 2 are displayed on the final output.

Also since Grid inside of Bloqs is not supported, I have no idea what this is doing to the performance. Bloqs is basically a Grid field, so putting a Grid inside of a Grid means that it is calling the same code that Bloqs is again (get_pair_field function you see in the trace), and doing a sub loop.

4) Unfortunately I don’t have any suggestions other than to re-build that page without using Bloqs. You’ll be able to re-build it faster than I can maybe find a way to improve Bloq’s parsing. I’ve done timed/conditional display of content like that before and each instance of content you want to display at a given time works much better as its own entry, then use a custom plugin or possibly native EE entries tag parameters to choose which entry to load. This way you’re only loading and parsing 2 entries, not 17. This sort of conditional display of content is similar to making a database query and pulling all the rows in a table, then iterating those rows and choosing which ones to display via a conditional in PHP or the template, where as the query should have been optimized to only pull the 2 rows you needed, and let MySQL do the heavy lifting, not a template parser.

I wish I had a better answer for you.

#8

BoldMinded (Brian)

For comparison, I have a site with 23 blocks on a page and it takes ~15 seconds to load in a local vagrant environment, which is a small server with limited memory. There are also several other things on this page leading to the high load time, so all 15 seconds isn’t just Bloqs. I know this b/c if I remove the Bloqs field from the template, it still takes ~11 seconds to load the home page, which means 23 blocks on a small local server un-cached takes about 4 seconds to render. On a larger production server, it would obviously be less time. To solve our load issues we statically cache the entire page, which then loads in under 1 second.

I know this isn’t an apples to apples comparison, but I feel like it is representative of the fact that Bloqs itself isn’t flawed, but its probably more of a matter of what your blocks consist of. If you add a ton of atoms, especially ones like a Relationship field, and a hacked in version of Grid that in and of themselves do sub-loops with their own parsing the load times are obviously going to increase. This is why I suggest that you re-factor your home page to not use Bloqs to render the content, and I can’t support something that Bloqs itself was never meant to support, which is a Grid field in a block.

#9

BoldMinded (Brian)

I’m going to close this ticket b/c Bloqs is doing unsupported things. As suggested you should probably refactor this page to not use Bloqs for that sort of conditional content display. Alternatively if you remove the Grid field within the Bloqs and can produce nearly the same slow load times, then I’d be happy to take another look at this (you’d need to send me a copy of the site files and db so I can test locally). Just re-open if you can show that the page loads as slow with no Grid fields inside of Bloqs.

Login to reply