1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Xenforo response is slow 20 seconds to load

Discussion in 'Troubleshooting and Problems' started by AUSFIFA, Jun 21, 2014.


    AUSFIFA Member

    Hi Guys

    We just started using Xenforo recently and have completely customized the forum to integrate with our main site. This includes SSO so only one account for the whole site... AUSFIFA.com

    At roughly the same time every night, the forum and only the forum takes about 20 seconds to load a page? I'm not too sure on how to troubleshoot this fault and was hoping for some help from development team and users alike. Keep in mind we have other tables within the main database for the rest of the site which load in about 0.6seconds so the site is fast but anything to do with xenforo takes 20 seconds to load when this fault occurs?

    This is very dissapointing, our hosting is shared business hosting with bandwidth and disk space caps but we barely use 25% of the resources available looking at the stats since we launched. It also cannot be hosting related because as stated, the database file itself has tables for the other parts of the site to function and they are loading extremely fast. Switching between forum posts, threads etc is loading after a long wait. It doesnt fail, it just takes a very long time.

    Can we please get some help, currently using version 1.3.1 I believe.

    Please help us fix this issue.

  2. Brogan

    Brogan XenForo Moderator Staff Member

    If it's happening at the same time every night then it sounds like a daily cron task may be responsible.
    Or possible some sort of server related script which is running then.

    Which cron tasks run at the time the problem occurs?

    AUSFIFA Member

    We have 3 cron tasks. 2 that run hourly, and 1 that runs every 15 minutes. They're completely unrelated to Xenforo. Please note that the other pages outside of Xenforo still load fast when this occurs. What would be the best way to debug this sort of thing?

    At this moment in time it's taking about 20 seconds to load Xenforo. This is the forum: http://www.ausfifa.com/forums/index.php

    Try clicking on the other parts of the site such as "Home" and "Pro Clubs". You'll see that they load insanely fast.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Only 3 cron tasks in the XenForo ACP?
    There should be many more than that.

    Try disabling all add-ons and testing again.
    If the problem stops then it is add-on related.

    AUSFIFA Member

    Oh sorry, thought you meant cron jobs within our cpanel.

    Cron Entries
    1. Update User Trophies Next Run: Jun 22, 2014 at 1:40 AM
    2. Feeder Next Run: Jun 22, 2014 at 1:42 AM
    3. Expire Temporary User Changes Next Run: Jun 22, 2014 at 1:42 AM
    4. Rebuild Board Totals Counter Next Run: Jun 22, 2014 at 1:43 AM
    5. Delete Expired Bans Next Run: Jun 22, 2014 at 1:45 AM
    6. Downgrade Expired User Upgrades Next Run: Jun 22, 2014 at 1:50 AM
    7. Handle Expired Warnings Next Run: Jun 22, 2014 at 1:55 AM
    8. Hourly Clean Up Next Run: Jun 22, 2014 at 2:10 AM
    9. User Group Promotions Next Run: Jun 22, 2014 at 2:20 AM
    10. Update View Counters Next Run: Jun 22, 2014 at 2:30 AM
    11. Record Daily Statistics Next Run: Jun 22, 2014 at 10:30 AM
    12. Daily Clean Up Next Run: Jun 22, 2014 at 1:00 PM
    Our issue occurs between say 11:30PM and is still going till now 1:37AM.
    Issue occurs before these cron jobs start and they are all enabled by the way.

    We dont have many addons running, only the Last Post Editor by Waindigo and Kotomi for header injection.
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Are you on shared hosting or a VPS/dedicated?

    You can try disabling all add-ons as a frist step, to cancel out any add-on related issues.

    Other than that, it may be a matter of monitoring the server to see if there is particularly high load at these times.
  7. ENF

    ENF Well-Known Member

    When I first entered your site, it was a 51sec load for the Forum page. On the 2nd try, it was ~20sec.


    When you were setting up the forum initially, did you have this problem at all?

    If you have a change log, you may want to step backwards through it to see if anything that was changed or modified, could be a potential root cause.

    But, since it happens at certain time, it does point to some or of job or task that is running and causing the slow response. (oddly, since the rest of the site functioning fine... )

    AUSFIFA Member

    Thanks for your reply guys, we really need to fix this issue.

    We are on a shared hosting business plan which is not your run of the mill unlimited everything rubbish. We have moderate disk space and bandwidth.

    The addons we use are simply to inject our header for our site, as you can see if you visit ausfifa.com - it will show our header, we really dont want to break it since our site is live.

    I need to speak with my co-partner about disabling Last Post Avatar and the implications.

    I very much doubt its the server because that would imply that the whole site is slow, we have all the tables within one big database sql, xenforo tables are in there as well. Thats why I cant make sense of why the rest of the site is super fast, 600ms max when zipping through but xenforo is slow?

    We have had this issue 3 x times now :( I will need to see what else can be done but our forum is very light and was purposely built this way, we moved most tasks such as messaging and profiles across to our site to minimise the reliance on xenforo but rather use its cool ajax features and clean style. When you click on a username, it actually takes you to our site rather than the xenforo forum profile. Also we removed conversations, anything excess.

    We are confused about this problem? we have to be the lightest xenforo install around :(
  9. ENF

    ENF Well-Known Member

    Having butchered it so much, it's hard to properly troubleshoot when the common pieces are really shifted around.

    My guess: Something is getting caught in a loop. Monitoring things such as DB utilization or slow queries during these events, could be a start. If it's really happening at a specific time, I'd focus on the jobs in XF and anywhere else that even remotely touches the processes that have anything to do with generating a page from the forum. When I see the index.php load run for that long of a time, I'd first check the DB response... but since the rest of the site is OK and it's using the same DB, then that is kind of ruled out. Other things that come in along the way: What is PHP doing? Just waiting or actually trying to do something? Caching? Any conflict happening in the cache that may be shared on your site? (if you're using caching, which I only assume that you are...)

    A good rule of thumb here is also double-check the most basic points and don't discount something because you have checked it already once before. Check it again. :)

    I'll be following this thread to see what the solution is. Good luck!
    AUSFIFA likes this.
  10. Brogan

    Brogan XenForo Moderator Staff Member

    As you are on shared hosting, contact the host and ask them to check the server load, resources, scripts, etc. for these times.
    It is possible another account is the problem.
    AUSFIFA likes this.

    AUSFIFA Member

    Will do guys, I'll report back once we work it out on our end.

    AUSFIFA Member

    We've managed to resolve the issue. Turns out it was one of our helpers which was causing a massive delay. I replaced the avatar helpers to grab avatars from my own site instead. What the helper was doing was it was checking first to see if the image existed on the server, and if it didn't it would display the default avatar instead. This was the code that was causing the massive slowdown. I removed this code and it's fixed.

    The problem now is that users who don't have custom avatars uploaded will have a broken image instead. What the helper does is it displays an avatar image based on the username of the user. Here's the code for my regular avatar helper:

    public static function helperAvatar ($user, $size)
    $src = "http://www.ausfifa.com/img/avatar/".$size."x".$size."/".$user.".png";

    if (@getimagesize($src))
    return "<a class='avatar NoOverlay' href=/profile.php?user=".$user."><img src='/img/avatar/".$size."x".$size."/".$user.".png'></a>";
    return "<a class='avatar NoOverlay' href=/profile.php?user=".$user."><img src='/img/avatar_default_".$size.".png'></a>";

    The IF statement checks to see if the image exists. If it doesn't exist it returns the default avatar image.

    I removed this IF statement now, and it's working fine, but I need to now find another way to display a default avatar if the user hasn't uploaded one. Does anyone know how I could achieve this?

    What I don't understand is why in gods name does this only perform badly at night? For the rest of the day it's fine. It's only in between around 9:30PM-3:00AM where it just becomes ridiculously slow all of a sudden.
  13. Snog

    Snog Well-Known Member

    Since the size is already set there's no point in getting the image size.

    Try this..
    if (file_exists($src))
    return "<a class='avatar NoOverlay' href=/profile.php?user=".$user."><img src='/img/avatar/".$size."x".$size."/".$user.".png'></a>";
    return "<a class='avatar NoOverlay' href=/profile.php?user=".$user."><img src='/img/avatar_default_".$size.".png'></a>";
    I don't know how much that will help, but it does avoid processing the image size for no reason.

    The problem could very well be just the action of checking every avatar on the disk. If that's the case, then you'd need to put a flag in your user table to indicate if there's an avatar or not. Then just check the flag. That would be much quicker.

    AUSFIFA Member

    We actually already have flags in the user database, 0 for default and 1 for custom avatar. We use this on the actual site. I had problems running SQL queries inside of the helper functions to check these flags, so I tried to do it another way by checking if the avatar exists. file_exists didn't work for me, and many other people didn't have much luck with it. The solution was to use @getimagesize, as that worked for almost everybody.
  15. oO5 Dynasty

    oO5 Dynasty Active Member

    I had a problem with my website beging slow and it was because i was using Slow azz ipage.com for my service provider. I have no changed to a Solid State Drive Hosting Service, and my website Loads Soooooooooooooooooooo Fast its incredible. Trust me i just made this move in 2015 and im sticking with this host. Plus the Prices are not bad, and they have a good rating.
  16. MQK8

    MQK8 Active Member

    ipage.com refused to allow me to install xenforo on their servers, they did me a huge favor.

Share This Page