For a user, the primary indicator of a good website is its loading speed! Research has shown that users are most satisfied when a website loads in 3 seconds or less, and if the loading time exceeds 10 seconds, 98% of users choose to close the website directly. Such severe user loss is a significant problem for website owners and businesses: no matter how well-designed the layout, how beautiful the visuals are, and how unbeatable the content is, they become useless in this context!! So, what should we do in such a situation?
Before analyzing and solving the problem, it is essential to understand the entire website system clearly. Is the website deployed on a single server or multiple servers? Is load balancing implemented? What is the website's current QPS (Queries Per Second), and how is the load distributed among the servers? It would be best to visualize the architecture for a clear understanding.
In addition, we also need to understand the underlying principles of browser requests. When a user enters a website address in the browser, it goes through a series of complex processes before the page is finally rendered. These processes include DNS resolution, TCP connection establishment, TLS handshake, browser parsing, and rendering (for a detailed process, refer to: https://github.com/alex/what-happens-when). Any issue in each of these steps can potentially lead to a decrease in the website's loading speed. So, how can we quickly identify the problem areas?
Firstly, to identify the reasons for slow website loading, there are usually several methods:
We generally need the cooperation of users to provide some basic information:
We can maintain communication with the customer and verify our assumptions through questioning, continuously eliminating impossible factors, and determining the direction of the investigation.
In addition to gathering information from users, we can also guide them to use browser packet capture for diagnostics. For example, Chrome has developer tools, and the network panel within it can analyze the timing of resource loading, view the loading time of each resource, and pinpoint the slow-loading resources. For detailed instructions, refer to: https://developer.chrome.com/docs/devtools/network/.
In addition to actively asking customers, we can also use automated diagnostic tools to quickly obtain basic information such as the client's IP, local DNS, and browser version. You can use the following link to access a tool for this purpose: http://debug.ping.dnsv1.com/ping.x.
Sometimes, to determine whether an issue is isolated or widespread, we can use third-party probing tools for troubleshooting. For example, you can use one-time probing tools like https://www.17ce.com/, or periodic probing systems provided by companies like Borui and Jidiao.
To quickly and proactively detect client-side anomalies, it is generally necessary to implement tracking and reporting logic in the business code. This involves reporting basic information such as page loading delays to the server for analysis, which is highly valuable for optimizing the page.
It's not only important to implement tracking and reporting logic within the page, but we also need to ensure proper monitoring on the server side. This includes reporting server-related information (CPU/memory/disk/TCP connections/file descriptors) and business metrics (request QPS, latency, thread pool size) to the monitoring system. With comprehensive monitoring in place, we can avoid blind troubleshooting and quickly validate hypotheses, eliminate interference, and pinpoint the root cause by following the monitoring trends.
The above are just a few examples of methods for analyzing and identifying problems. In practice, we often need to use a combination of various approaches to find the issues.
Once we have identified the root cause, we can propose targeted solutions.
If the issue concerns the client's network or DNS resolution, they should contact their local network service provider for resolution.
In most cases, this indicates that the server is overwhelmed by the number of requests and its resources are exhausted. To address this, you can consider the following options:
This indicates that the server is functioning properly, but the business-side processing capacity is insufficient. Possible reasons include:
Slow network transmission can occur when the client and server are on different networks or in different regions. In such cases, optimizing the entire protocol stack can be beneficial.
Overall, integrating the website with EdgeOne is the easiest, most cost-effective, and most effective way to accelerate performance.
Finally, let's use an example of a static website to demonstrate the effects of applying these optimization techniques.
This is an example page from AdminLTE3, with many resources being loaded on the homepage. By sorting the loading times from longest to shortest, we can see that before optimization, the page took a total of 8.48 seconds to load. The adminlte.min.css file alone took 4.68 seconds, which was the most time-consuming.
Upon inspecting the server response, we can see that headers like Transfer-Encoding and Content-Encoding are missing, indicating that compression is not enabled.
We configure the Nginx server to enable compression and observe the results.
We can see that the loading time for adminlte.min.css is reduced to 724ms, which is only 15% of the previous time. The overall website loading time is now 6.02s, which is lower than the previous 8.48s.
The server response headers now include Content-Encoding and Transfer-Encoding.
Let's explain the process of integrating with Tencent EdgeOne, which can be done in just a few simple steps to enable CDN acceleration.
In the Tencent EdgeOne console, the simplest operation is to enter the acceleration domain and the source server IP, then confirm and submit to create the domain configuration.
After creating the domain configuration, a CNAME will be assigned, which is crucial for EdgeOne integration. We only need to add a CNAME record pointing to this assigned CNAME for the original domain.
The final DNS resolution relationship should look like this:
Tencent EdgeOne has enabled security protection features for static sites by default, among other functions, as shown in the figure. Readers can explore on their own.
Access the website again. Since the requests are served by the nearest CDN nodes, the loading latency is further reduced. The overall loading time is now only 3.24s, significantly faster than the 6.02s after enabling compression on the original site.
There are many ways to optimize the loading speed of a website. Developers with the necessary skills and a love for tinkering can speed up the process by adjusting software design, architecture, and server configurations. In addition to this, the simplest and most convenient method is to connect the website to a CDN (Content Delivery Network), quickly enabling compression and QUIC features. This achieves the goal of saving costs, providing flexibility, and significantly increasing speed.