
as the default port of HTTP protocol, port 80 carries most of the external access requests of Web services, and its performance directly determines the user's access experience and service carrying capacity. However, in high concurrency scenarios, port 80 often has problems such as overflow of connection queues and increased response delays, which affect service availability. This article will share the specific methods and practices of port 80 performance improvement from connection management, resource allocation, protocol optimization, etc., to help operation and maintenance personnel accurately locate and solve the performance bottleneck of port 80.
connection establishment and release is one of the core sources of 80-port performance loss, and a reasonable connection management strategy can greatly reduce the consumption of invalid resources.
1 Enable TCP connection multiplexing mechanism
default, HTTP/1.1 protocol has supported long connections, but some servers are not turned on or configured improperly. Operations personnel can enable the Keep-Alive function in Nginx, Apache and other servers, set the appropriate connection timeout time and maximum number of requests, so that multiple requests from the same client can reuse the same 80-port TCP connection, avoid frequent three handshakes and four waving overhead, and reduce the frequency of 80-port connection creation.
2, optimize the 80 port connection queue parameters
when the concurrent requests of port 80 exceed the processing capacity of the server, the requests that are not processed in time will enter the waiting queue. By adjusting the net.core.somaxconn parameters of the Linux system and the listen_backlog parameters of the server, the length of the connection queue of port 80 can be expanded to avoid the request being rejected directly due to queue overflow. At the same time, combined with the connection timeout setting, the idle connections can be cleaned up in time to release the resource occupation of port 80.
server CPU, memory, bandwidth and other quotas are unreasonable, will lead to 80 ports can not give full play to the processing capacity, targeted resource allocation optimization is the basis for improving the performance of 80 ports.
1, adjust the number of processes and threads on port 80
according to the number of CPU cores of the server, reasonably set the number of service processes and threads corresponding to port 80. For example, Nginx can set the number of processes consistent with the number of CPU cores through worker_processes parameters, and set the maximum number of connections for a single process worker_connections parameters, so that the request processing of port 80 can make full use of multi-core CPU resources to avoid single process overload or idle resources.
2, configure port 80 static resource cache
static resource requests account for more than 70% of the total requests on port 80, static resources such as pictures, CSS, JS are distributed through CDN, or cached locally on the server, so that port 80 does not need to process the same static resource requests repeatedly, reducing the computation and IO overhead of port 80. At the same time, a reasonable cache expiration time can be set to maximize the cache hit rate while ensuring the freshness of resources.
HTTP protocol versions will directly affect the request processing efficiency of port 80, and upgrading to a more efficient protocol can improve the performance of port 80 from the bottom up.
1 Enable HTTP/2 for port 80
HTTP/2 protocol supports multiplexing, header compression, server push and other features, allowing the same 80-port TCP connection to handle multiple requests at the same time, solving the problem of HTTP/1.1 queue blocking. Operations personnel can configure HTTP/2 support in the server, allowing the client side to automatically negotiate the use of HTTP/2 protocol, greatly improving the concurrent request processing capacity of 80 ports and reducing user waiting time.
2 Enable 80-port header compression
HTTP request and response header information contains a large number of duplicate fields, enabling gzip or Brotli compression algorithms can compress the header data volume transmitted on port 80 to less than 30% of the original, reducing the network transmission volume of port 80 and improving data transmission efficiency. At the same time, pay attention to setting appropriate compression levels for different types of resources to balance compression efficiency and CPU overhead.
too many security checks or invalid requests will consume the processing resources of port 80, the security reduction optimization allows port 80 to focus on the processing of valid requests.
1, configure access control policies for port 80
set IP whitelist or blacklist for port 80 through the access control module of the firewall or server to intercept invalid requests such as scanning and crawling from malicious IP, and reduce the amount of useless request processing on port 80. At the same time, the request frequency limit can be configured to limit the number of requests for the same IP in unit time to prevent port 80 from being overwhelmed by malicious requests.
2, Simplify the security verification process of port 80
on the premise of ensuring security, simplify the 80-port identity verification and permission verification process, such as setting the static resources accessed at high frequency to no verification, or using cookies to cache the verification results to avoid repeated execution of complex verification logic for each request, reducing the CPU computation overhead of port 80.
To sum up, the performance optimization of port 80 is a systematic work, which needs to be promoted in multiple dimensions from connection management, resource allocation, protocol upgrade, and security burden reduction. By enabling TCP reuse, adjusting connection queues, upgrading HTTP/2, and configuring cache policies, etc., it can effectively reduce the resource consumption of port 80, improve concurrent processing capacity and response speed, provide users with a smoother Web access experience, and ensure the stability and carrying capacity of services.