Topic-icon Slow Time To First Byte

Active Subscriptions:

None
10 years 11 months ago #53609 by fb_1627387670
Hi there,

After running hundreds tests with GTmetrix .com I came to the conclusion that plugin System - JFBCSystem add about 1.45 second of TTFB for my website, so I went to dig in the php source code of that plugin, when I remove the line "$this->buildListOfTagsToReplace();" from public function onAfterInitialise() my TTFB goes to about 0.3 sec, which was the time that I initially had before installing JFBC.

Of course, by removing the above line from the source code, all the JFBC tags aren't parsed anymore, but there it demonstrate an issue ! I know I'am not alone to have this problem here, I have seen other post about it. like this recent one : www.sourcecoast.com/forums/jfbconnect/jf...th-jfbconnect-active

The issue occur on every page, whatever the pages contain JFBC tags or not. Doesn't matter if others JFBC plugin are enabled or not, if I disable JFBCSystem plugin the TTFB is good.

I have a high performance server located in France, 60% of the resources of my server is unexploited, it is definitely not a problem from server side. Also, my Mysql is set to another server on SSD.

Please fix this problem soon as you can, or give me a work around or any solution.

Joomla 2.5.28
JFBC Version: 6.4.0
System cache plugin enabled - file cache
JFBC cache enabled
website : www.rikoooo.com

Thank you,

Best regards,

Erik
The topic has been locked.
Support Specialist
10 years 11 months ago #53612 by alzander
Replied by alzander on topic Slow Time To First Byte
Erik,
The function you mention is an intensive function. That's why one of the first lines in that block is:
$tagsToReplace = JFBCFactory::cache()->get('system.alleasytags');
That check is to load the results from cache if they are available. You mention that you have JFBC cache enabled. Can you tell us:
* What is the setting for the cache duration in JFBConnect?
* Do you have the Debug Mode option enabled in JFBConnect?
If debug is enabled, the cache is off automatically. If the cache duration is too short, or you're clearing your cache between GTMetrix runs, then you're testing the worst case scenario.

You can also try to add some code into that block to echo out if the tags are being re-parsed. If they are being re-built on every page load, then something is definitely going wrong. The cache is crucial to good performance for that block.

Another issue I see is how we do the parsing of tags altogether. To find and replace tags, we have to scan the page using a regular expression to find any tags that look like they are from JFBConnect. Your site looks to be using inline images in the page, which increases the overall response size. While that can improve the downloading of image performance, it can slow down our scanning time. I wouldn't expect an additional 1s to do so, but a larger HTML response would cause some delay in our parsing.

I hope that helps get you started, but please let me know if there's anything else we can help with.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 11 months ago #53613 by fb_1627387670
Alex, Thank you.

JFBC Connect cache is set to 15 minutes
Debug mode is disabled in JFBC.

Well, I have for instance disabled mod_pagespeed from Apache and another plugin that was making inline base64 image. Then I ran few test with GTmetric, result is identical, TTFB is above 1.4-5 seconde (still way too much). For now, I have re-enabled those plugins because they aren't the cause of the issue.

What code should I put in function onAfterInitialise() to echo out if the tags are being re-parsed ? Because that might be a path that needs exploring.

Best regards,

Erik
The topic has been locked.
Active Subscriptions:

None
10 years 11 months ago - 10 years 11 months ago #53615 by fb_1627387670
Hi again,

After few hours of work I finally came out with a work around (let's call it temporary fix ?) Here is a Howto that I hope will help everyone who's concern by the issue :

I've found out that parsing the tag {JFBCFan} from regex was causing a high latency on my server, why ? I didn't figured it out yet I'm not php expert.

However, I made a fix that needs a little hack of JFBCSystem plugin.

Open ../plugins/system/jfbcsystem/jfbcsystem.php

Find (line 320) : $regex = '/\{('.$this->scTags.'|JFBC|JLinked)(.*?)}/i';

Replace with : $regex = '/\{(?!JFBCFan)('.$this->scTags.'|JFBC|JLinked)(.*?)}/i';

Save

What it does is changing the regex code by avoiding to parse the tag {JFBCFan}, after this hack the tag will not work anymore, so if you were using this tag then you have to go here developers.facebook.com/docs/plugins/page-plugin and create your Facebook fan page code automatically, you only need the plugin code, not SDK Javascript because JFBC Connect already include it, then past the code instead of your {JFBCFan} tag or where you want.

Remember, after this you must empty your joomla cache, then load for example your home page 1 or 2 times before it takes into effect.

Right now my TTFB is back to normal on my test site (0.4 sec over main page instead of 1.5 sec or 1.8 sec, it's a big gain !), soon I'll apply the hack to the production site.

Thank you.

Best regards,

Erik
Last edit: 10 years 11 months ago by fb_1627387670.
The topic has been locked.
Support Specialist
10 years 11 months ago #53617 by alzander
Replied by alzander on topic Slow Time To First Byte
Erik,
I'm glad you've found something that works for you. Unfortunately, I don't understand how or honestly believe that not scanning for the {JFBCFan} tag would have that sort of performance improvement. That block of code is simply 'scanning' for that tag in the page. If the tag isn't found on the page, absolutely no additional code is executed. That means that if the fix you presented is really what was necessary on your site, there's something wrong with regular expressions searches on your server. That could be a PHP or underlying server OS issue.

On your main site, I'm still seeing the 1.6s wait. However, if I test your home page, initially I see a redirect to the /en/ page. That redirect alone takes .56s, which means that *even before* JFBConnect does the regex you're changing above, there's a .56s delay built-in to the page load time.

Finally, we haven't seen this issue before and do a ton of work to keep loading times down. You're free to test this site and see that the 'waiting' time is well under 1s on all pages. The post you showed above also was ultimately narrowed down to *not* be from JFBConnect. There was a post from me which showed there was huge variability on the server. Also, most of the loading time came from the SCSocialStream module which was causing the delay because it was loading many avatar images from Facebook. That's not similar to the issue you're explaining.

I hope that helps,
Alex
The topic has been locked.