Website becomes inaccessible due to high host CPU or memory usage

Updated at:

High CPU or memory usage on a Cloud Web Hosting instance can cause your website to become inaccessible. This topic describes the possible causes of and solutions for this issue.

Symptoms

After you build a website on a Dedicated Cloud Web Hosting instance, the website becomes inaccessible after a period of time.

Possible causes

Your Cloud Web Hosting site may experience a malicious attack. An incorrect configuration in a file, such as the .htaccess file, can also cause this issue. These events can lead to high CPU or memory usage on the Cloud Web Hosting instance, which results in your website becoming inaccessible.

Note

Many factors can cause a website to become inaccessible. This topic focuses on high host CPU or memory usage as an example. For more information, see Website access issues.

Solutions

The solutions in this topic apply only to Dedicated Cloud Web Hosting instances. The steps provided use a Dedicated Cloud Web Hosting instance that runs a standard Linux operating system as an example.

  1. Log on to the Cloud Web Hosting management page.
  2. For the Dedicated Cloud Web Hosting instance with the inaccessible site, click Manage in the Actions column.

  3. In the navigation pane on the left, click Host Information.
  4. In the Monitoring Information section, identify the time when the CPU or memory usage of the Cloud Web Hosting instance peaked at 100%.

    This example shows the CPU usage reaching 100%. Hover your mouse pointer over the CPU monitoring graph to view the exact time when the usage reached 100%. In this case, the time is 10:05:00 on February 15, 2023.

  5. In the Monitoring Information section, on the Statistics by Source IP tab, you can hover over the time when CPU usage peaked to view and record the IP addresses or IP address ranges with an excessive number of connections. These are the abnormal IP addresses or IP address ranges.

    Note

    When you hover your mouse pointer over the time of peak CPU usage, you can also view the connection time, total number of connections, number of source IPs, and the number of connections from each IP address.

    This example shows an IP address with an excessive number of connections at 10:05:00 on February 15, 2023: TOP0:39.xxx.xxx.xxx.IP地址

    • If there is an abnormal IP address, block it. Go to Step 6 and then proceed to Step 9.

    • If an IP address range is abnormal, use the connection limiting feature to restrict the number of concurrent connections from it. Go to Step 7 and then continue to Step 9.

    • If many IP addresses from different address ranges are abnormal, use the connection limiting feature to restrict the number of concurrent connections from each IP address. Go to Step 8 and then proceed to Step 9.

  6. (Optional) Block the abnormal IP address.

    1. In the left navigation pane, click Access Control.

    2. On the IP Block tab, click Add IP.

    3. In the Add IP dialog box, enter the abnormal IP address in the IP field and click OK.

    After the abnormal IP address is added, it appears in the IP address list.屏蔽IP

  7. (Optional) Limit the number of concurrent connections from each abnormal IP address range.

    1. In the left navigation pane, click Access Control.

    2. Click the Connection Limit tab.

    3. In the Connection Limit Settings section, complete the following steps depending on the Connection Limit Status:

      • If the status is Disabled, click [Enable Limit].

      • If the status is Enabled, click Modify Limit.

    4. In the Enable Limit or Modify Limit dialog box, change the Concurrent Connection Limit, click Advanced Configuration, and then change the Connection Mask to 24.

      For example, if you set Concurrent Connection Limit to 10 and Connection Mask to 24, each source IP in a class C IP address range can have up to 10 connections.修改连接数

    5. Click OK.

  8. (Optional) Limit the number of concurrent connections from each abnormal IP address.

    1. In the left navigation pane, click Access Control.

    2. Click the Connection Limit tab.

    3. In the Connection Limit Settings section, click [Modify Limit].

    4. In the Modify Limit dialog box, change the Concurrent Connection Limit, click Advanced Configuration, and then change the Connection Mask to 32.

      For example, if you set the Concurrent Connection Limit to 10 and the Connection Mask to 32, each source IP can have a maximum of 10 connections.32掩码

    5. Click OK.

  9. In the left navigation pane, click Site Information. In the Server Monitoring section, check the CPU and memory usage.

    • If the CPU and memory usage of the Cloud Web Hosting instance is still high, proceed to Step 10.

    • If the CPU and memory usage of the Cloud Web Hosting instance is within the normal range, the procedure is complete.

    Note

    You should evaluate whether the CPU and memory usage of your Cloud Web Hosting instance is high or normal based on your business needs.

  10. (Optional) Check the .htaccess file for configuration errors and modify it as needed.

    The following steps show how to check the .htaccess file configuration on a Dedicated Cloud Web Hosting instance that runs a standard Linux operating system:

    1. In the left navigation pane, choose File Management > File Manager.

    2. Click Site Root Directory, find the .htaccess file, and click View in the Actions column.

      文件管理

    3. Check and modify the .htaccess file.

      For example, the .htaccess file contains the following content:

      Options+FollowSymLinks
      IndexIgnore*/*
      RewriteEngine on
      # If the directory exists, access it directly
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      # If the directory does not exist, redirect to index.php
      RewriteRule.index.php

      After checking the .htaccess file, you find that the RewriteRule.index.php configuration item redirects all requests for non-existent paths to index.php. This can cause a continuous increase in website access requests. You can then modify or comment out the RewriteRule.index.php configuration item as needed.

    Important

    To prevent your website from becoming inaccessible due to high CPU or memory usage on your Cloud Web Hosting instance, you can set up Custom Monitoring Alarms on the Host Information page. If the CPU or memory usage exceeds the alarm threshold, you will receive an alert. You can then use the solutions in this topic. For more information about setting up custom monitoring alarms, see Get host and site information for a Cloud Web Hosting instance.