Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

HTTP performance optimization

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Through the above figure, you can optimize the performance of HTTP from three aspects.

1. Server

The main metrics to measure server performance are as follows:

A. Throughput (or TPS, RPS, QPS)

B. concurrent number

C. response time

D. Resource utilization (CPU, memory, hard disk, network)

-- > increase throughput, the higher the throughput, the better the performance of the server!

-- > increase the number of concurrency, the greater the number of concurrency supported, the better the performance of the server!

-- > reduce the response time, the shorter the response time, the better the performance of the server!

-- > rational use of server resources, too high is definitely not good, too low may also be a problem!

-- > the main monitoring tools of Linux server are top, sar, glances, etc.

two。 Client

Because the data is obtained from the server through the network, its most basic performance indicator is: delay.

The so-called "delay" is actually "waiting", the time spent waiting for the data to arrive at the client.

The reasons for the delay are as follows:

A. distance: delays caused by geographical distance cannot be served by customers, such as visiting websites thousands of kilometers away.

B. bandwidth

C.DNS query (if the domain name is not cached locally)

D.TCP handshake (must go through three packets of SYN, SYN/ACK and ACK before establishing a connection)

For HTTP performance optimization, there is a dedicated testing site: WebPageTest, or developer tools using browsers

-- > the delay in the process of HTTP "request-response" is very large and may account for more than 90%.

-- > so, the key to client optimization is to reduce latency

3. Transmission link (transmission link between client and server)

Using CDN and other technologies, in short, it is necessary to increase the bandwidth, reduce the delay and optimize the transmission speed.

-specific optimization means-

The main purpose is to optimize the performance of the server.

1. Front-end: you can use tools such as PageSpeed to detect and optimize according to prompts.

two。 Backend: there are mainly the following aspects

a. Hardware, software, or service

Such as replacing powerful CPU, memory, disk, bandwidth, etc., such as using CDN

b. Server selection, parameter tuning

Select high-performance servers, such as Nginx, whose powerful reverse proxy capability can achieve "static and dynamic separation", give dynamic pages to Tomcat, and static resources to Nginx.

In addition, Nginx itself has parameters that can be tuned, such as disabling load balancing locks, increasing the connection pool, binding CPU, etc.

Persistent connections must be enabled for the HTTP protocol, because the cost of establishing a new connection between TCP and SSL is very high and may account for more than half of the total client latency

TCP's new feature "TCP Fast Open", similar to TLS's "False Start", can transfer data during the first handshake, enabling this feature in the operating system and Nginx as much as possible, reducing handshake delays in both the external and intranet networks.

Using the built-in "data compression" encoding of the HTTP protocol, you can choose the standard gzip or try a new compression algorithm br

However, in data compression, we should pay attention to choosing the appropriate compression ratio, not the more severe the compression, the better.

c. Caching

Within the website system, special caching services such as Memcache and Redis can be used to store intermediate results and resources in memory or hard disk.

The Web server first checks the cache system and returns it to the client immediately if there is any data

In addition, CDN's network acceleration is based on caching, so to speak, if there is no cache, then there is no CDN.

The key to making good use of the cache function is to understand how it works, add ETag and Last-modified fields for each resource, and then set cache control properties with Cache-Control and Expires.

The most basic of these is the max-age validity period, which marks the time when the resource can be cached. For static resources such as pictures, CSS, etc., you can set a long time, such as one day or

One month, for dynamic resources, unless it is very real-time, you can also set a short time, such as 1 second or 5 seconds. So that once the resource reaches the client, the

Will be cached and no more requests will be sent to the server during the validity period.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report