The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Website Freezes on PHP pages on certain devices at random intervals?

Discussion in 'Workarounds and Optimization' started by davellan, Oct 26, 2015.

  1. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    So I just migrated servers (from Hostgator to LiquidWeb) and noticed a huge improvement in speed (load time from 20s+ to 4.5s).

    While I am very happy about that, several of my staff and customers have complained about not being able to access my sites for brief periods of time. I have also experienced this issue as well.

    It seems to occur on php pages. A person will try to access a page, and it will time out trying to load it. I can load other website accounts on the server that use php, but not on that account. It also is only one device that gets affected (regardless of browser used). For example, I have tested it out where my phone cannot login, but my lap top can. Then later on, it is the reverse situation - my phone logins in fine but my laptop cannot.

    This happens on Wordpress pages, and also on a custom php API script that I have on one of my accounts.

    If I login to the WHM and kill all processes from that user, then they are able to use the site again.

    I have tech support from LiquidWeb looking into it, but I was hoping that maybe someone here has had this happen before and can point me in the right direction.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,481
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Assuming these are the same site, I think I might try disabling anything customized like this, any WP addons or custom theme as well, for starters, to see if the issue persists.
     
  3. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    These are on different sites. One account has php scripts I use for API integrations.

    I have other accounts that are just for WP membership sites. Each account is completely independent of the other.
     
  4. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    How is your PHP configured? DSO or FastCGI?
    If FastCGI - do you have limit of processes per user?
    Before you kill processes - how many processes are there running?

    My suggestion is that new hosting company has either less CPU cores or has less CPU cycles or it's being granted in other way. but again it also might be something tunable in PHP config to make resource spreading more fair.
     
  5. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    I believe I do have FastCGI, not sure if there is a limit on processes per user. How and where would I check?

    The new host has more cores and a better processor than previous host, so I don't think hardware is an issue.

    They said they fixed something over the weekend, and so far I haven't seen the issue reproduced since Monday, but still testing with my staff to see if it is indeed fixed for good. Trying to figure out what they did to fix, if indeed it is fixed, for future reference.
     
  6. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    Ugh, bug strikes again.

    There are 7 open processes all accessing the same page, which is timing out only on Firefox and IE, but on Chrome it works fine (all on the same PC).

    I can access the root domain (test.com) but not (test.com/myapiroot).

    After further testing, it seems to be a php sessions problem.

    I use a login code as follows:

    PHP:
    // If page requires SSL, and we're not in SSL mode,
    // redirect to the SSL version of the page
    if($_SERVER['SERVER_PORT'] != 443) {
       
    header("HTTP/1.1 301 Moved Permanently");
       
    header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
       exit();
    }
    // put sha1() encrypted password here
    $password 'sha1passwordgoeshere';

    session_start();
    if (!isset(
    $_SESSION['loggedIn'])) {
        
    $_SESSION['loggedIn'] = false;
    }

    if (isset(
    $_POST['password'])) {
        if (
    sha1($_POST['password']) == $password) {
            
    $_SESSION['loggedIn'] = true;
        } else {
            
    $logFailure true;
        }
    }

    if (!
    $_SESSION['loggedIn']):
    // Load Login Page
    exit();
    endif;
    ?>
    This code is included on all my PHP pages at the top.

    I use below for logout:
    PHP:
    // If page requires SSL, and we're not in SSL mode,
    // redirect to the SSL version of the page
    if($_SERVER['SERVER_PORT'] != 443) {
        
    header("HTTP/1.1 301 Moved Permanently");
        
    header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
        exit();
    }

    // Initialize the session.
    // If you are using session_name("something"), don't forget it now!
    session_start();

    // Unset all of the session variables.
    $_SESSION = array();

    // If it's desired to kill the session, also delete the session cookie.
    // Note: This will destroy the session, and not just the session data!
    if (ini_get("session.use_cookies")) {
        
    $params session_get_cookie_params();
        
    setcookie(session_name(), ''time() - 42000,
            
    $params["path"], $params["domain"],
            
    $params["secure"], $params["httponly"]
        );
    }

    // Finally, destroy the session.
    session_destroy();
    I can clear cookies and cache to restore accessibility, but that is an issue I don't want to occur to my staff or customers. Been googling for solutions but none have worked for me so far.

    It seems to juggle between working with Chrome, Firefox, or IE on my PC.
     
  7. tank

    tank Well-Known Member

    Joined:
    Apr 12, 2011
    Messages:
    236
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    The fine people of Cpanel will tell you the Fast CGI is not recommended Cpanel. It works and does the job just fine but you have to tweak it. What are the values for your Fast CGI?
     
  8. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    Well, I have seemed to resolve the issue just by editing some code on my php pages.

    My logout page used a input submit form to return to a login page, and replacing that with a standard anchor tag seemed to fix part of the problem.

    The other part seemed to be linked to my landing page after login. For whatever reason, there is a section of code that while it executes fine from the user perspective, the error log gets a foreach expecting an array error (that is clearly getting an array, because it is executing the code using an array fine). Removing that code seemed to end the issue entirely.

    I am indeed using FastCGI, and below are the settings that I got from phpinfo()

    Code:
    cgi-fcgi
    Directive    Local Value    Master Value
    cgi.check_shebang_line    1    1
    cgi.discard_path    0    0
    cgi.fix_pathinfo    1    1
    cgi.force_redirect    1    1
    cgi.nph    0    0
    cgi.redirect_status_env    no value    no value
    cgi.rfc2616_headers    0    0
    fastcgi.logging    1    1
    However, at the moment it seems I have no more issues, and haven't been able to replicate the problem myself, nor have my customers reported it since.
     
  9. tank

    tank Well-Known Member

    Joined:
    Apr 12, 2011
    Messages:
    236
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    Here is an example of what I am talking about.
    MaxRequestsPerProcess 1000
    DefaultMaxClassProcessCount 120
    IdleTimeout 60
    MaxProcessCount 2000
    IPCCommTimeout 40
    IPCConnectTimeout 10
    MaxRequestLen 10240000
     
  10. davellan

    davellan Member

    Joined:
    Jun 26, 2014
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Daniels, WV
    cPanel Access Level:
    Root Administrator
    Twitter:
    Where would I fine this in the WHM?
     
  11. tank

    tank Well-Known Member

    Joined:
    Apr 12, 2011
    Messages:
    236
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    This is where you find those variables
    Home » Service Configuration » Apache > Include Editor

    On that page go to the bottom click on Post virtualhost include, then click on all versions. Post what you have.
     
    #11 tank, Oct 31, 2015
    Last edited by a moderator: Oct 31, 2015
Loading...

Share This Page