Source returning method and device and readable storage medium

By aggregating origin requests for the same domain name into the same worker thread of the tunnel node in the content delivery network, the problem of low origin connection reuse rate is solved, achieving efficient resource utilization and reducing the load on the origin server.

CN121864792APending Publication Date: 2026-04-14CHINANETCENT TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In a content delivery network, multiple resource requests are randomly assigned to different processes, resulting in low reuse rate of back-to-origin connections, wasting cache node resources and increasing the load on the origin server.

Method used

By aggregating origin requests for the same domain to the same worker thread on the tunnel node, origin requests for the same domain can reuse the same origin connection between the tunnel node and the origin server, and are processed uniformly using the hash-bound tunnel and worker thread.

Benefits of technology

It improves the reusability of back-to-origin connections, avoids wasting cache node resources, reduces the load on the origin server, and improves back-to-origin efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121864792A_ABST
    Figure CN121864792A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a back-to-source method and device and a readable storage medium, and after a first cache node determines that resources requested by a first resource request are not cached locally, a first back-to-source request is sent to a first tunnel node through a first tunnel. And after the first tunnel node receives the first back-to-source request, when a back-to-source connection corresponding to the first domain name exists in a connection pool of the first working thread, the back-to-source connection corresponding to the first domain name is multiplexed to back to the source of the first back-to-source request, and the back-to-source connection is used for connecting the first tunnel node and the source station. By adopting the scheme, the back-to-source requests of the same domain name are converged to the same working thread of the tunnel node, and the tunnel node uses the same working thread as much as possible to uniformly back to the source for the back-to-source requests of the same domain name; therefore, the same back-to-source connection between the tunnel node and the source station is multiplexed as much as possible by the back-to-source request of the same domain name, the reuse rate of the back-to-source connection is improved, the resource of the cache node is prevented from being wasted, and the load of the source station is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of content delivery network technology, and in particular to a method, device and readable storage medium for returning to the source. Background Technology

[0002] Content Delivery Networks (CDNs) are widely used because they distribute content to users from the nearest location, which greatly improves access speed and reduces the load on the origin server.

[0003] Typically, a content delivery network (CDN) consists of an origin server and cache nodes distributed across different regions. The cache nodes employ a multi-process model. When a cache node receives a resource request from a terminal device, the request is randomly assigned to a process. If the cache node already has the requested resource cached locally, the process returns the resource to the terminal device. If the cache node does not have the requested resource cached locally, a back-to-origin connection is established between the process and the origin server to retrieve the resource from the origin server and cache it locally. Retrieving resources from the origin server is called a back-to-origin connection.

[0004] When multiple resource requests require origin server connections, these resource requests may be assigned to different processes. Each process establishes an origin server connection between the cache node and the origin server, resulting in multiple origin server connections. This seriously wastes the resources of the cache node and increases the load on the origin server. Summary of the Invention

[0005] This application provides a back-to-origin method, device, and readable storage medium. By aggregating back-to-origin requests for the same domain name to the same working thread of the tunnel node, the back-to-origin requests for the same domain name can reuse the same back-to-origin connection between the tunnel node and the origin server as much as possible. This improves the back-to-origin connection reuse rate, avoids wasting cache node resources, and reduces the load on the origin server.

[0006] In a first aspect, embodiments of this application provide a source traversal method applied to a first tunnel node, the method comprising: The first origin request is received from the first process of the first cache node through the first tunnel. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node. The first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread of the first tunnel node. The hash value of the first domain name is the first hash value. When the first worker thread has a back-to-origin connection corresponding to the first domain name in its connection pool, it reuses the back-to-origin connection corresponding to the first domain name to back-to-origin the first back-to-origin request. The back-to-origin connection is used to connect the first tunnel node and the origin station.

[0007] Secondly, embodiments of this application provide a back-to-origin method applied to a first cache node, the method comprising: The first resource request from the terminal device is assigned to the first process of the first cache node, and the first resource request carries the first domain name; When the first cache node does not cache the resource requested by the first resource request locally, it sends a first origin request to the first tunnel node through the first tunnel, so that the first worker thread of the first tunnel node processes the first origin request. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread, and the hash value of the first domain name is the first hash value.

[0008] Thirdly, embodiments of this application provide a first source return device, which is integrated on a first tunnel node, and the first source return device includes: The transceiver module is used to receive a first origin request from a first process of a first cache node through a first tunnel. The first origin request carries a first domain name. The first tunnel is a tunnel between the first process and the first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to a first worker thread of the first tunnel node, and the hash value of the first domain name is the first hash value. The processing module is used to reuse the origin connection corresponding to the first domain name to return the first origin request when there is an origin connection corresponding to the first domain name in the connection pool of the first worker thread. The origin connection is used to connect the first tunnel node and the origin station.

[0009] Fourthly, embodiments of this application provide a second source-return device, which is integrated on a first cache node. The second source-return device includes: The processing module is configured to allocate a first resource request from the terminal device to a first process of the first cache node, wherein the first resource request carries a first domain name; The transceiver module is used to send a first origin request to a first tunnel node through a first tunnel when the first cache node does not cache the resource requested by the first resource request locally, so that the first worker thread of the first tunnel node processes the first origin request. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread, and the hash value of the first domain name is the first hash value.

[0010] Fifthly, embodiments of this application provide an electronic device on which a first cache node and a first tunnel node are deployed. The electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it causes the electronic device to implement the method described in the first aspect or various possible implementations of the first aspect; or, when the processor executes the computer program, it causes the electronic device to implement the method described in the second aspect or various possible implementations of the second aspect.

[0011] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, are used to implement the method described in the first aspect or various possible implementations of the first aspect; or, when executed by a processor, the computer instructions are used to implement the method described in the second aspect or various possible implementations of the second aspect.

[0012] In a seventh aspect, embodiments of this application provide a computer program product comprising a computing program, wherein when the computer program is executed by a processor, it implements the method described in the first aspect or various possible implementations of the first aspect; or, when the computer program is executed by a processor, it implements the method described in the second aspect or various possible implementations of the second aspect.

[0013] The origin pull method, device, and readable storage medium provided in this application embodiment involve a first cache node determining that the resource requested by the first resource request is not cached locally. The first cache node then sends a first origin pull request to a first tunnel node through a first tunnel. This first origin pull request carries a first domain name. The first tunnel is a tunnel between a first process and a first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to a first worker thread of the first tunnel node, and the hash value of the first domain name is the first hash value. Upon receiving the first origin pull request, if the first worker thread's connection pool contains an origin pull connection corresponding to the first domain name, the first tunnel node reuses that connection to pull the first origin pull request. The origin pull connection connects the first tunnel node and the origin server. This approach aggregates origin pull requests for the same domain name to the same worker thread of the tunnel node. For origin pull requests with the same domain name, the tunnel node uses the same worker thread as much as possible to perform unified origin pulls, ensuring that origin pull requests for the same domain name reuse the same origin pull connection between the tunnel node and the origin server. This improves the reusability of origin pull connections while avoiding wasting cache node resources and reducing the load on the origin server. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1A This is a schematic diagram of the traditional source tracing method; Figure 1B yes Figure 1A Schematic diagram of the distribution of the source-return connection; Figure 2A This is a schematic diagram of a network architecture to which the back-to-source method provided in this application applies; Figure 2B This is a schematic diagram of another network architecture to which the back-to-source method provided in this application is applicable; Figure 3 This is a flowchart of the source-return method provided in the embodiments of this application; Figure 4 This is an interaction diagram of the source-following method provided in the embodiments of this application; Figure 5 This is another interaction diagram of the source-following method provided in the embodiments of this application; Figure 6A This is a schematic diagram of the source-return method provided in the embodiments of this application; Figure 6B yes Figure 6A Schematic diagram of the distribution of the source-return connection; Figure 7 This is a schematic diagram of the first source return device provided in the embodiments of this application; Figure 8 This is a schematic diagram of the second source return device provided in the embodiments of this application; Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0016] A Content Delivery Network (CDN) is a network architecture widely used for distributing internet content. By deploying caching nodes around the world, CDNs distribute content from the origin server to the caching nodes closest to the user, significantly improving content distribution efficiency, reducing pressure on the origin server, and enhancing user access speed and experience.

[0017] To improve service stability, concurrency handling capabilities, and security, the cache nodes employ a multi-process model; for example, a single cache node might have 20 processes. When a cache node receives a resource request, it is randomly assigned to one of the processes. Since the cache node caches the vast majority of content, the actual percentage of resource requests requiring origin server lookups is extremely small and distributed across different processes. During origin server lookups, each process establishes a separate connection with the origin server, resulting in low connection reuse. Furthermore, establishing origin server connections requires complex Secure Sockets Layer (SSL) handshake processes, increasing initial packet time. Simultaneously, establishing multiple origin server connections significantly wastes cache node memory and other resources and increases the load on the origin server.

[0018] Figure 1A This is a schematic diagram of the traditional source tracing method. Please refer to it. Figure 1A Clients 1 through 4 send resource requests to the cache node, each carrying the same domain name, example.com, and are randomly assigned to one of four processes. For example, client 1's request is assigned to process A, client 2's to process B, client 3's to process C, and client 4's to process D. The cache node does not locally store resources related to example.com and needs to perform a backhaul to the origin server. During the backhaul, process 1 establishes backhaul connection a with the origin server, process 2 establishes backhaul connection b with the origin server, process 3 establishes backhaul connection c with the origin server, and process 4 establishes backhaul connection d with the origin server.

[0019] Figure 1B yes Figure 1A A schematic diagram showing the distribution of the source-return connections. Please refer to... Figure 1A and Figure 1B When four clients request resources from the same domain, if the four resource requests are randomly assigned to four processes, each process establishes an independent origin connection with the origin server during the origin server connection process. This results in a 0% reuse rate for the origin server connection, which seriously wastes the resources of the cache nodes and increases the load on the origin server.

[0020] Furthermore, due to the long network distances between cache nodes and the origin server, as well as the use of encrypted origin connections, establishing new origin connections takes a considerable amount of time. Additionally, some origin servers impose strict limits on the number of origin connections that can be established.

[0021] Based on this, embodiments of this application provide a back-to-origin method, device, and readable storage medium. By aggregating back-to-origin requests for the same domain name to the same working thread of the tunnel node, the tunnel node uses the same working thread to uniformly perform back-to-origin requests. This enables back-to-origin requests for the same domain name to reuse the same back-to-origin connection between the tunnel node and the origin server, thereby improving the back-to-origin connection reuse rate while avoiding wasting cache node resources and reducing the load on the origin server.

[0022] Figure 2A This is a schematic diagram of a network architecture to which the back-to-source method provided in this application applies. Please refer to... Figure 2A The network architecture includes at least terminal equipment 21, electronic equipment 22, and source station 23.

[0023] Terminal device 21 includes, for example, mobile phones, tablets, laptops, and desktop computers. The operating system of terminal device 21 can be Linux, Windows, Android, etc. A client is installed on terminal device 21, including but not limited to applications (apps) such as browsers and video software. Resource requests are triggered when a user uses the client. For example, while watching a video through video software, a user continuously sends resource requests to cache node 221 to request video content.

[0024] Origin site 23, such as a server, is used to store various resources, including but not limited to videos, images, web pages, software installation packages, etc.

[0025] A cache node 221 and a tunnel node 222 are configured on electronic device 22. That is, cache node 221 and tunnel node 222 are deployed on the same physical machine. Cache node 221 is also known as a CDN node, CDN cache node, cache server, etc. Cache node 221 is used to cache resources pulled from origin server 23, while tunnel node 222 serves cache node 221, responsible for hiding the address of origin server 23, encrypting the back-to-origin link 23, and optimizing cross-network transmission, allowing cache node 221 to focus on efficiently serving user resource requests.

[0026] Cache node 221 adopts a multi-process model, and one cache node 221 can run multiple processes, such as 10 processes, 20 processes, etc. Only processes A, B, C, and D are shown in the diagram. Each process is connected to tunnel node 222 via a tunnel. There can be multiple tunnels between a process and tunnel node 222; only one is shown in the diagram. After receiving a resource request from terminal device 21, cache node 221 randomly assigns the resource request to a process. If cache node 221 has already cached the requested resource locally, the process returns the resource to the terminal device. If cache node 221 has not cached the requested resource locally, the process will not directly return to the origin server; that is, the process will not directly establish a return-to-origin connection with the origin server. Instead, it sends a return-to-origin request to tunnel node 222 through the tunnel, and tunnel node 222 retrieves the resource from the origin server 23. These resources include videos, images, web pages, software installation packages, etc.

[0027] Tunnel node 222 employs an architecture consisting of a main thread and multiple worker threads. The main thread is used to allocate worker threads to tunnels during tunnel establishment, ensuring that tunnels bound to the same hash value are handled by the same worker thread. This means that origin requests transmitted through the tunnel are processed by the same worker thread. Each worker thread has its own independent event loop, responsible for handling origin requests, etc., and the processing logic of different worker threads is isolated from each other.

[0028] In this embodiment, a tunnel is established between the process and tunnel node 222, and a back-to-origin connection is established between tunnel node 222 and the origin server. Multiple tunnels can be established between a process and tunnel node 222, each bound to a hash value. The hash values ​​of different tunnels can be the same or different. When a process sends a back-to-origin request to tunnel node 222, if there is no tunnel between the process and tunnel node 222, or even if one or more tunnels have been established between the process and tunnel node 222, but none of the established tunnels correspond to the hash value of the domain name of the back-to-origin request, a new tunnel is established between the process and tunnel node 222. Since a tunnel can only transmit one back-to-origin request at a time, when multiple back-to-origin requests carrying the same domain name are generated sequentially, these back-to-origin requests reuse the same tunnel; when multiple back-to-origin requests are concurrent, multiple tunnels are established between the process and tunnel node 222, these tunnels correspond to the same hash value, and these tunnels are assigned to the same worker thread.

[0029] In this embodiment, multiple tunnels can be established between a process and tunnel node 222. Each tunnel is bound to a hash value, and the hash values ​​of different tunnels can be the same or different. For example, if multiple origin requests carry different domain names, and the hash values ​​of different domain names are different, and these origin requests are not concurrent requests, then multiple tunnels are established, and the corresponding tunnels are allocated according to the hash values ​​corresponding to different domain names. Since the hash values ​​of the same domain name are the same, origin requests of the same domain name are sequentially passed to the tunnel node through the same tunnel.

[0030] For example, if multiple origin requests carry the same domain name, and these origin requests are concurrent, then multiple tunnels are established, each bound to the same hash value, and one origin request is transmitted through one tunnel at a time.

[0031] For example, multiple origin requests may carry different domain names. These origin requests are concurrent, and each domain name has the same hash value. In this case, multiple tunnels are established between the process and the tunnel node, with each tunnel bound to the same hash value. At any given time, one tunnel transmits one origin request.

[0032] In this embodiment, the same process of the same cache node 221 sends origin requests to the tunnel node 222 at different times. If the hash values ​​of the domain names carried by these origin requests are the same, the same tunnel is reused. Furthermore, these origin requests are processed by the same worker thread of the tunnel node 222, and origin requests for the same domain name return to the origin through the same origin connection, that is, the origin connection is reused.

[0033] In this embodiment, different processes of the same cache node 221 send origin requests to tunnel node 222 at different times through different tunnels. If the hash values ​​of the domain names carried by these origin requests are the same, they are processed by the same worker thread of tunnel node 222. Origin requests for the same domain name return to the origin through the same origin connection, that is, the origin connection is reused.

[0034] As can be seen from the above, in this embodiment of the application, by aggregating the origin requests of the same domain name into the same origin connection, it is not necessary for each process to establish an origin connection with the origin server separately. Instead, the origin requests of different processes reuse the same origin connection.

[0035] The above Figure 2A In this context, origin requests from the same process on the same cache node, carrying the same domain name, can reuse the same origin connection; similarly, origin requests from different processes on the same cache node, carrying the same domain name, can also reuse the same origin connection. However, this embodiment is not limited to this; for example, origin connections can be reused across cache nodes. For an example, please refer to... Figure 2B .

[0036] Figure 2B This is a schematic diagram of another network architecture to which the back-to-source method provided in this application applies. Please refer to... Figure 2B The network architecture contains multiple electronic devices 22, each of which deploys a cache node 221 and a tunnel node 222, forming a cache node group. Each cache node 221 can run multiple threads. Taking an electronic device 22-1 and an electronic device 22-2 as an example, electronic device 22-1 contains a cache node x and a tunnel node m, and electronic device 22-2 contains a cache node y and a tunnel node n. Process A of cache node x sends an origin request carrying the domain name www.a.com to tunnel node m, and process D of cache node y sends an origin request carrying the domain name www.a.com to tunnel node n. Since these two origin requests carry the same domain name, www.a.com, they return to the origin through the same origin connection, such as the origin connection between tunnel node m and origin server 23.

[0037] It should be noted that, although the above figure Figure 2A and 2BThe example described above uses the deployment of tunnel node 222 and the corresponding cache node 221 on the same electronic device, i.e., the same physical machine. However, this embodiment is not limited to this. In other optional implementations, cache node 221 and tunnel node 222 can also be deployed on different physical machines in the same data center, and the tunnel node 222 corresponding to cache node 221 can be flexibly configured.

[0038] Below, based on Figure 2A and Figure 2B The architecture shown illustrates the source-following method described in the embodiments of this application. For example, please refer to... Figure 3 , Figure 3 This is a flowchart of the back-to-origin method provided in this application embodiment. This embodiment describes the interaction between a tunnel node and a cache node deployed on the same electronic device. The first cache node and the first tunnel node are deployed on the same electronic device; the first tunnel node can be referred to as the tunnel node corresponding to the first cache node. Similarly, the second cache node and the second tunnel node are deployed on the same electronic device. This embodiment includes: 301. The first cache node assigns the first resource request from the terminal device to the first process of the first cache node, and the first resource request carries the first domain name.

[0039] In this embodiment of the application, the domain names such as the first domain, second domain, third domain, and fourth domain can be either first-level domains or second-level domains. An example of a first-level domain is example.com, and examples of second-level domains are teiba.exampl.com, map.example.com, and www.example.com.

[0040] When a user accesses the internet using their terminal device, they continuously send first resource requests to the first cache node. The first cache node randomly assigns the first resource request to a process, hereinafter referred to as the first process.

[0041] 302. The first cache node sends the first origin request to the first tunnel node through the first tunnel.

[0042] Accordingly, the first tunnel node receives the first origin request from the first process of the first cache node through the first tunnel.

[0043] In this embodiment, after the first process receives the first resource request, if the first cache node has already cached the resource requested by the first resource request locally, the first process returns the resource to the terminal device. If the first cache node has not cached the resource requested by the first resource request locally, the first process will not directly establish a back-to-origin connection with the origin server, but will instead determine whether a first tunnel exists between the first process and the first tunnel node. If a first tunnel exists between the first process and the first tunnel node, the first back-to-origin request is sent to the first tunnel node through the first tunnel. If no first tunnel exists between the first process and the first tunnel node, a new first tunnel is created, and the first back-to-origin request is sent to the first tunnel node through the first tunnel.

[0044] In this embodiment, each tunnel is bound to a hash value. The first tunnel is bound to the first hash value. The hash value of the first domain name carried in the first origin request is the first hash value.

[0045] In this embodiment, the hash values ​​of different domain names can be the same or different. For example, if there are 1000 domain names, after deduplication, there are 6 different hash values. The number of hash values ​​matches the number of worker threads, so origin requests for domains carrying the same hash value can be assigned to the same worker thread. Alternatively, if there are 1000 domain names, a modulo operation is performed on the initial hash value of each domain name to match the number of remainders. For example, with 7 worker threads, the hash value modulo 7 results in remainders of 0, 1, 2, 3, 4, 5, and 6, allowing the 1000 domain names to be evenly distributed among the 7 worker threads.

[0046] 303. When there is a back-to-origin connection corresponding to the first domain name in the connection pool of the first worker thread, reuse the back-to-origin connection corresponding to the first domain name to make the first back-to-origin request. The back-to-origin connection is used to connect the first tunnel node and the origin station.

[0047] In this embodiment, the first tunnel node adopts an architecture of a main thread plus multiple worker threads. The number of worker threads is not limited to, for example, 6 or 8. Different worker threads correspond to different hash values, and these hash values ​​are bound to the tunnel. Therefore, after receiving the first origin request through the first tunnel, the first tunnel node can determine the first worker thread based on the first tunnel.

[0048] In this embodiment, an independent connection pool is maintained for each worker thread, and different origin pull connections in the connection pool correspond to different domain names. When an origin pull connection corresponding to the first domain name exists in the connection pool, there is no need to create a new origin pull connection; instead, the existing connection is reused to fetch resources from the origin server. When no origin pull connection corresponding to the first domain name exists in the connection pool, a new origin pull connection is created, and the origin pull is performed through the newly created connection. Obviously, if the first tunnel node receives multiple first origin pull requests, since each first origin pull request carries the same first domain name, these first origin pull requests will use the same origin pull connection to pull the origin. That is, origin pull requests with the same domain name use the same worker thread to pull the origin and pull the origin through the same origin pull connection.

[0049] Additionally, when the first tunnel node determines the origin connection from the connection pool, it can also combine IP address and port information. Each origin connection in the connection pool corresponds to a set of domain name, IP address, and port. The first origin request carries an IP address, such as the IP address of the origin server determined by the caching node. The first tunnel node queries the connection pool to see if a corresponding origin connection exists based on the first domain name, IP address, and port. If an origin connection corresponding to the first domain name, IP address, and port exists in the connection pool, there is no need to create a new origin connection; instead, the existing origin connection is reused to fetch resources from the origin server. If no origin connection corresponding to the first domain name, IP address, and port exists in the connection pool, a new origin connection is created, and the origin request is executed through the newly created connection.

[0050] In practice, the cache nodes sequentially receive the first resource requests carrying the first domain name, and these requests are randomly assigned to different processes. If an origin pull is required, each process sends its first origin pull request to the first tunnel node through its own first tunnel. Each time the first tunnel node receives a first origin pull request, it uses the same first worker thread to perform a unified origin pull, even if the resources requested by these first origin pull requests are different. For example, if first origin pull request 1 and first origin pull request 2 both carry the first domain name www.a.com, but first origin pull request 1 requests an image and first origin pull request 2 requests a video, the first tunnel node still uses the first worker thread to perform a unified origin pull for these first origin pull requests. Clearly, these first origin pull requests reuse the same origin pull connection.

[0051] The origin pull method provided in this application involves a first cache node determining that the resource requested by the first resource request is not cached locally. The first cache node then sends a first origin pull request to a first tunnel node via a first tunnel. This first origin pull request carries a first domain name. The first tunnel is a tunnel between a first process and a first tunnel node, and it is bound to a first hash value. The first hash value is assigned to a first worker thread of the first tunnel node, and the hash value of the first domain name is the first hash value. Upon receiving the first origin pull request, if the first worker thread's connection pool contains an origin pull connection corresponding to the first domain name, the first tunnel node reuses that connection to pull the first origin pull request. This origin pull connection connects the first tunnel node and the origin server. By aggregating origin pull requests for the same domain name to the same worker thread of the tunnel node, the tunnel node uses the same worker thread as much as possible to perform unified origin pulls for requests with the same domain name. This ensures that origin pull requests for the same domain name reuse the same origin pull connection between the tunnel node and the origin server as much as possible, thereby improving the reusability of origin pull connections while avoiding wasting cache node resources and reducing the load on the origin server.

[0052] Optionally, in the above embodiments, when the first cache node does not locally cache the resource requested by the resource request, before sending the first origin pull request to the first tunnel node through the first tunnel, the first cache node further determines whether there exists a first tunnel bound to the first hash value between the first process and the first tunnel node. When there is no first tunnel between the first process and the first tunnel node, the first cache node sends a target message to the first tunnel node, the target message carrying the first hash value of the first domain name. Then, the first cache node and the first tunnel node establish the first tunnel between the first process and the first tunnel node according to the target message, and the first tunnel node allocates the first worker thread for the first hash value.

[0053] In this embodiment, when the first cache node does not cache the resource requested by the first resource request locally, if a tunnel has not yet been established between the first process and the first tunnel node, the first process and the first tunnel node communicate to establish a first tunnel. If one or more tunnels have been established between the first process and the first tunnel node, the first cache node determines whether a first tunnel exists among the established tunnels. If a first tunnel exists among the established tunnels, it is reused; otherwise, a new first tunnel is created. The existence of a first tunnel among the established tunnels means that there exists a tunnel whose hash value is a first hash value, which is the hash value of the first domain name.

[0054] During the establishment of the first tunnel, the first cache node determines the first hash value of the first domain name and writes it into the target packet. The first process of the first cache node sends the target packet to the first tunnel node; correspondingly, the first tunnel node receives the target packet from the first process. The target packet carries the first hash value of the first domain name. Then, the first process and the first tunnel node establish the first tunnel based on the target packet. Simultaneously, the main thread of the first tunnel node allocates a worker thread for the first hash value, i.e., the first worker thread. Allocating a first worker thread for the first hash value means allocating a first worker thread for the first tunnel.

[0055] In this embodiment, the target message is, for example, a Synchronize Sequence Numbers (SYN) message. The first cache node writes the first hash value into the Transmission Control Protocol (TCP) option of the SYN message and sends the SYN message to the first tunnel node to perform the first handshake.

[0056] After receiving the SYN packet, the first tunnel node sends an ACK packet and a SYN packet to the first process, thus completing the second handshake. After receiving the ACK and SYN packets, the first process sends an acknowledgment response to the first tunnel node, thus completing the third handshake. After the three-way handshake, the first tunnel is established between the first process and the first tunnel node. The main thread of the first tunnel node allocates a worker thread for the first hash value, i.e., the first worker thread. Since each hash value is bound to a tunnel, allocating a worker thread for a hash value is equivalent to allocating a worker thread for a tunnel.

[0057] The embodiments of this application do not limit the way worker threads are allocated. For example, if the first hash value is 1, then worker thread a is allocated as the first worker thread to the first hash value; as another example, if the first hash value is 2, then worker thread b is allocated as the first worker thread to the first hash value.

[0058] In this embodiment, the first cache node and the first tunnel node are deployed on the same electronic device. The first tunnel is a tunnel between the first process and the first tunnel node; that is, the first tunnel is an internal tunnel of the electronic device. The first tunnel is much shorter than the connection between the electronic device and the origin server, and the handshake time is very short. Moreover, communication within the electronic device, i.e., between the first process and the first tunnel node, uses a tunneling method, eliminating the need for complex SSL handshake processes. Therefore, the overhead of establishing the first tunnel is very low.

[0059] It should be noted that although the embodiments of this application are illustrated by taking the deployment of the first cache node and the first tunnel node on the same electronic device as an example, the embodiments of this application are not limited thereto. In other optional implementations, the first cache node and the first tunnel node can also be deployed on different physical machines in the same data center, and the first tunnel node corresponding to the first cache node can be flexibly configured.

[0060] Furthermore, the number of hash values ​​is the same as the number of worker threads. For a single process, such as the first process, as long as the hash values ​​of the domain names of different resource requests from the first process are the same, they can communicate with the first tunnel node using the same first tunnel. Because the first tunnel is frequently reused, it can be maintained for a longer period of time, thus serving more first resource requests.

[0061] For the same domain, such as the first domain, the first tunnel node uses the same worker thread to handle all origin pull requests. Since the CDN actually doesn't handle many origin pull requests, a single origin pull connection can serve a large number of origin pull requests when concurrency is low.

[0062] In this scheme, when the first process sends the first origin request to the first tunnel node, if there is no reusable first tunnel, the first hash value is carried in the target message and sent to the tunnel node, thereby establishing a reliable first tunnel between the first process and the first tunnel node, and allocating a unique first working thread for the first tunnel to ensure that the origin request can be transmitted to the first tunnel node in an orderly and secure manner, thereby improving the origin efficiency.

[0063] Optionally, in the above embodiments, during the process of the first tunnel node allocating the first worker thread to the first hash value, the first tunnel node first determines the number of concurrent tunnels. A concurrent tunnel is a tunnel currently established by the first worker thread, and each concurrent tunnel is bound to the first hash value. When the number of concurrent tunnels is less than a preset threshold, the first worker thread is allocated to the first hash value.

[0064] In this embodiment, the first tunnel can only transmit one first origin request at a time. When multiple first origin requests carrying the first domain name are generated sequentially, these first origin requests reuse the first tunnel. When multiple first origin requests are concurrent, multiple first tunnels are established between the first process and the first tunnel node. These first tunnels are all bound to the first hash value, and these first tunnels are assigned to the same first worker thread, which is equivalent to the tunnels currently established by the first worker thread. In this case, these first tunnels are called concurrent tunnels.

[0065] The more concurrent tunnels there are, the heavier the load on the first worker thread and the lower its health. Conversely, the fewer concurrent tunnels there are, the lighter the load on the first worker thread and the higher its health. To avoid overloading the first worker thread, the first tunnel node determines whether the number of concurrent tunnels is less than a preset threshold. Only when the number of concurrent tunnels is less than the preset threshold is a first worker thread allocated to the first hash value and a new first tunnel established. The preset threshold may be, for example, 2000, 3000, or 500, and is not limited in this embodiment.

[0066] When the number of concurrent tunnels is greater than or equal to a preset threshold, other worker threads are allocated to the first hash value. These other worker threads are responsible for handling the origin pull for the latest received first origin pull request. Clearly, the origin pull connection for the first origin pull request is different from the origin pull connection for the first origin pull request transmitted through a concurrent tunnel.

[0067] This approach determines whether the first worker thread is overloaded each time a new tunnel is created. Only when the first worker thread is under light load will the first origin request be made through the first worker thread, ensuring that the load of each worker thread in the first tunnel node is balanced.

[0068] Optionally, in the above embodiments, when the number of concurrent tunnels is greater than or equal to a preset threshold, a second worker thread is allocated to the first hash value, and the second worker thread is the first worker thread in the sequence list after the first worker thread.

[0069] In this embodiment, a sequence list is set on the first tunnel node, indicating the order of each worker thread. When a new first tunnel needs to be created, if the main thread finds that the number of concurrent tunnels already established by the first worker thread is relatively large, in order to avoid overloading the first worker thread, i.e., to ensure the health of the first worker thread, the first tunnel node assigns a second worker thread to the first hash value. This second worker thread is the first worker thread in the sequence list after the first worker thread. For example, there are a total of 6 hash values ​​and 6 worker threads, where the 6 hash values ​​are hash values ​​1 to 6 and the 6 worker threads are worker threads a to f. The main thread assigns worker thread a to hash value 1, worker thread b to hash value 2, and so on. Assuming the first hash value is hash value 2, when the number of first tunnels currently established between the first process and the first tunnel node is greater than 2000, i.e., when the number of first tunnels handled by the first worker thread is relatively large, it indicates that the first worker thread is overloaded. In this case, since the next worker thread after worker thread b in the sequence list is worker thread c, and worker thread c has a lower load, the first tunnel node assigns the first hash value to worker thread c.

[0070] In this scheme, when the first worker thread is under high load, the first tunnel node assigns the first hash value to the second worker thread, which is under lower load and closer to the first worker thread. This ensures that even when the load of multiple worker threads is uneven, the origin requests for the same domain name can still be concentrated on a few worker threads, thereby reusing the origin connection as much as possible.

[0071] Optionally, in the above embodiments, during the process of a user accessing the internet using a terminal device, a second resource request carrying a second domain name is continuously sent to the first cache node. The first cache node randomly assigns the second resource request to a process, assuming it is assigned to the first process. The second hash value of the second domain name is the same as the first hash value. After the first process receives the second resource request, if the first cache node has already cached the resource requested by the second resource request locally, the first process returns the resource to the terminal device. If the first cache node has not cached the resource requested by the second resource request locally, it sends a second origin request to the first tunnel node through the first tunnel. Correspondingly, the first tunnel node receives the second origin request from the first process of the first cache node through the first tunnel. The second origin request carries a second domain name, and the second hash value of the second domain name is the same as the first hash value. When there is an origin connection corresponding to the second domain name in the connection pool of the first worker thread, the origin connection corresponding to the second domain name is reused to return the second origin request.

[0072] For example, before the first process receives the second resource request, it has already established a first tunnel with the first tunnel node, and this first tunnel is bound to the first hash value. Therefore, after the first process receives the second resource request, although the second resource request carries the second domain name, a second hash value is obtained after hashing the second domain name, and this second hash value is equal to the first hash value. That is, the first domain name and the second domain name are different domain names, but they correspond to the same hash value. In this case, there is no need to create a new tunnel; instead, the first tunnel is reused, that is, the first process of the first cache node sends the second origin request to the first tunnel node through the first tunnel.

[0073] After receiving the second origin request, the first tunnel node processes it using the first worker thread. Although different second origin requests all carry a second domain name, the resources requested by different second origin requests are different. For example, second origin request 3 and second origin request 4 both carry the second domain name www.b.com, but second origin request 3 requests an image, while second origin request 4 requests a video.

[0074] The connection pool of the first worker thread contains multiple origin pull connections, each corresponding to a set of domain names, IP addresses, and ports. Clearly, the first origin pull request and the second origin pull request carry different domain names; therefore, the origin pull connections corresponding to the first and second origin pull requests are different, but both belong to the connection pool of the first worker thread.

[0075] Furthermore, since there are multiple first-origin requests carrying the same first domain name, if these requests share the same IP address and port, they will use the same origin connection. Similarly, since there are multiple second-origin requests carrying the same second domain name, if these requests share the same IP address and port, they will use the same origin connection. In other words, for origin requests with the same domain name, the first tunnel node uses the same worker thread to handle the unified origin connection, and all origin requests with the same domain name use the same origin connection.

[0076] In this approach, when resource requests carrying different domain names are assigned to the same first process, if all requests require origin pulls and the hash values ​​of the domain names are the same, the first process reuses the same tunnel to send origin pull requests to the first tunnel node, thereby improving tunnel reuse rate. Simultaneously, for origin pull requests of the same domain name, the first tunnel node uses the same worker thread to perform unified origin pulls, and origin pull requests of the same domain name use the same origin pull connection, thereby improving the reuse rate of origin pull connections.

[0077] In the above embodiments, if the first process sends multiple first origin requests to the first tunnel node, these first origin requests are assigned to the same first worker thread. That is, different first origin requests from the same first process use the same worker thread for unified origin requests. However, this application embodiment is not limited, and in other feasible implementations, origin requests from different processes can also use the same worker thread for unified origin requests.

[0078] Optionally, in the above embodiments, the first cache node allocates a third resource request from the terminal device to the second process of the first cache node. When the first cache node does not cache the resource requested by the third resource request locally, it sends a third origin pull request to the first tunnel node through the second tunnel. Correspondingly, the first tunnel node receives the third origin pull request from the second process of the first cache node through the second tunnel. When there is an origin pull connection corresponding to the third domain name in the connection pool of the first worker thread, the origin pull connection corresponding to the third domain name is reused to retrieve the third origin pull request. The third origin pull request carries a third domain name, the second tunnel is a tunnel between the second process of the first cache node and the first tunnel node, and the third hash value of the third domain name is the same as the first hash value.

[0079] When a user accesses the internet using their terminal device, they continuously send third-party resource requests carrying third-party domain names to the first cache node. The first cache node randomly assigns these requests to a process; let's say it assigns one to the second process. The third hash value of the third domain name is the same as its first hash value. For example, if the third domain name and the first domain name are the same, then the third hash value of the third domain name is the same as its first hash value. Similarly, if the third domain name and the second domain name are the same, then the third hash value of the third domain name is the same as its first hash value. Even if the first, second, and third domain names are different domain names, but their hash values ​​are the same, the hash values ​​of the first, second, and third domain names can still be different.

[0080] After the second process receives the third resource request, if the first cache node has already cached the requested resource locally, the second process returns the resource to the terminal device. If the first cache node has not cached the requested resource locally, it sends a third origin request to the first tunnel node through the second tunnel. Correspondingly, the first tunnel node receives the second origin request from the second process of the first cache node through the second tunnel. For details on the creation and reuse of the second tunnel, please refer to the description of the first tunnel; it will not be repeated here.

[0081] Since the second process and the first process are different processes of the first cache node, the tunnel between each process and the first tunnel node is independent, so tunnels cannot be reused between processes. However, since the second tunnel is also bound to the first hash value, the worker thread corresponding to the second tunnel is also the first worker thread, just like the first tunnel. After receiving a third origin request, the first tunnel node uses the first worker thread to process the third origin request. Although different third origin requests all carry the third domain name, the resources requested by different third origin requests are different. For example, third origin requests 5 and 6 both carry the third domain name www.c.com, but third origin request 5 requests an audio file, while third origin request 6 requests an installation package. Obviously, third origin requests for the same domain name are all handled by the first worker thread for unified origin requests.

[0082] Assuming the third domain and the first domain are the same, although the first origin request comes from the first process and the third origin request comes from the second process, when the first worker thread's connection pool has an origin connection corresponding to the third domain, that connection is reused to handle the third origin request. Clearly, when the third domain and the first domain are the same, the tunnel node uses the same worker thread to handle both the first and third origin requests uniformly, and the first origin request for the first domain and the third origin request for the third domain reuse the same origin connection between the tunnel node and the origin server.

[0083] This approach allows origin requests from different processes to be assigned to the same worker thread, enabling the first tunnel node to use the same worker thread to handle origin requests from different processes, thereby improving the reusability of origin connections.

[0084] In the above embodiments, multiple first origin requests from the first process are uniformly returned to the origin by the same first worker thread, thereby improving the origin connection reuse rate. Alternatively, origin requests from different processes on the same cache node are uniformly returned to the origin by the same first worker thread, thereby improving the origin connection reuse rate. These different processes are, as described above, the first and second processes. In both cases, the reuse of origin connections is for the same cache node; that is, multiple processes on a single machine will aggregate origin requests for the same domain name to the same worker thread on the first tunnel node. However, the embodiments of this application are not limited to reusing origin connections for different origin requests within a single cache node. Origin connections can also be reused across cache nodes, meaning that origin requests from different cache nodes are assigned to the same worker thread and uniformly returned to the origin by the same first worker thread. In other words, if multiple cache nodes form a cache node group, these cache node groups can further aggregate origin requests for the same domain name in the same way, further improving the origin connection reuse rate.

[0085] Optionally, in the above embodiments, the second cache node and the first cache node are different cache nodes in the same cache node group. During the process of a user accessing the internet using a terminal device, they continuously send a fourth resource request carrying a fourth domain name to the second cache node. The second cache node randomly assigns the fourth resource request to a process, assuming it is assigned to the fourth process of the second cache node. The fourth hash value of the fourth domain name is the same as the first hash value. After the fourth process receives the fourth resource request, if the second cache node has already cached the requested resource locally, the fourth process returns the resource to the terminal device. If the second cache node has not cached the requested resource locally, it sends a fourth origin request to the second tunnel node through a third tunnel. The third tunnel is a tunnel between the fourth process and the second tunnel node bound to the first hash value. Correspondingly, the second tunnel node receives the fourth origin request from the fourth process of the second cache node through the third tunnel. For details on the creation and reuse of the third tunnel, please refer to the description of the first tunnel; it will not be repeated here.

[0086] Please refer to Figure 2B With a one-to-one correspondence between cache nodes and tunnel nodes, the cache node in electronic device 22-1 is the first cache node, and the tunnel node in electronic device 22-1 is the first tunnel node. The cache node in electronic device 22-2 is the second cache node, and the tunnel node in electronic device 22-2 is the second tunnel node. The fourth process of the second cache node sends a fourth origin request to the second tunnel node through the third tunnel. After receiving the fourth origin request, the second tunnel node forwards it to the first tunnel node. In this way, the first tunnel node assigns the fourth origin request to the first worker thread, which then handles the unified origin requests.

[0087] Assuming the fourth domain and the first domain are the same, although the first origin request originates from the first process of the first cache node and the fourth origin request originates from the fourth process of the second cache node, when an origin connection corresponding to the fourth domain exists in the connection pool of the first worker thread, that connection is reused to handle the fourth origin request. Clearly, because the fourth domain and the first domain are the same, the first tunnel node uses the same worker thread to handle both the first and fourth origin requests uniformly, and the first origin request for the first domain and the fourth origin request for the fourth domain reuse the same origin connection between the tunnel node and the origin server.

[0088] This approach, by allocating origin requests from different cache nodes to the same worker thread, allows the first tunnel node to use the same worker thread to handle origin requests from different cache nodes, further improving the reusability of origin connections. Simultaneously, optimizing the allocation and use of tunnel nodes enhances the stability and reliability of the CDN network.

[0089] Figure 4 This is an interaction diagram of the origin pull method provided in this application embodiment. In this embodiment, after a first tunnel has been established between the first process and the first tunnel node, the first process sends a first origin pull request to the first tunnel node. That is, this embodiment is described from the perspective of reusing the first tunnel. This embodiment includes a client request stage, a first cache node processing stage, an origin pull connection reuse stage, and an origin pull response stage. This embodiment includes the following steps: Client request phase: 401. The terminal device sends a first resource request to the first cache node.

[0090] The first resource request includes the first domain name, which is example.com.

[0091] First cache node processing stage: 402. The first cache node randomly assigns the first origin request to the first process.

[0092] 403. The first cache node determines that a back-to-origin request is required.

[0093] When the first cache node does not cache the resource requested by the first resource request locally, the first cache node determines that it needs to retrieve the resource from the origin server.

[0094] 404. The first cache node sends the first origin request to the first tunnel node.

[0095] When the first cache node determines that a back-to-origin request is needed, it determines the first hash value based on the first domain name and checks whether a first tunnel bound to the first hash value exists between the first process and the first tunnel node. If a first tunnel bound to the first hash value exists between the first process and the first tunnel node, the first process of the first cache node sends the first back-to-origin request to the first tunnel node through the first tunnel.

[0096] Origin connection reuse phase: 405. The first tunnel node checks the connection pool of the first worker thread.

[0097] If a corresponding origin connection for the first domain exists in the connection pool, proceed to step 406; if no corresponding origin connection for the first domain exists in the connection pool, proceed to step 407.

[0098] 406. Determine to reuse the source connection.

[0099] 407. The first tunnel node interacts with the source station to establish a new back-to-source connection.

[0100] 408. The first tunnel node adds the back-to-origin connection to the connection pool of the first worker thread.

[0101] Source Response Phase: 409. The first tunnel node sends the first back-to-source request to the source station through the back-to-source connection.

[0102] 410. The first tunnel node receives the first back-source response from the source station via the back-source connection.

[0103] The first origin response carries the resource requested in the first origin request.

[0104] 411. The first tunnel node sends the first source response to the first cache node.

[0105] The first worker thread of the first tunnel node sends the first origin response to the first cache node through the first tunnel.

[0106] 412. The first cache node sends the first resource response to the terminal device.

[0107] After receiving the first origin response, the first cache node parses the resource requested by the first resource request from the first origin response, generates the first resource response, and sends it to the terminal device.

[0108] Figure 5 This is another interaction diagram of the origin pull method provided in this application embodiment. In this embodiment, the first tunnel has not yet been established between the first process and the first tunnel node, or a new first tunnel needs to be established between the first process and the first tunnel node due to concurrent first origin pull requests. This embodiment includes a client request stage, a first cache node processing stage, a first tunnel establishment and worker thread allocation stage, a distribution stage, an origin pull connection reuse stage, and an origin pull response stage. This embodiment includes the following steps: Client request phase: 501. The terminal device sends a first resource request to the first cache node.

[0109] The first resource request includes the first domain name, which is example.com.

[0110] First cache node processing stage: 502. The first cache node randomly assigns the first origin request to the first process.

[0111] 503. The first cache node has determined that a back-to-origin request is required.

[0112] When the first cache node does not cache the resource requested by the first resource request locally, the first cache node determines that it needs to retrieve the resource from the origin server.

[0113] Phase 1 of tunnel construction: 504. The first cache node sends the target message to the first tunnel node.

[0114] The first cache node sends a target packet, such as a SYN packet, to the main thread of the first tunnel node. The TCP option of the SYN packet carries the first hash value.

[0115] 505. Assign the first worker thread to the first hash value.

[0116] 506. Establish the first tunnel between the first process and the first tunnel node.

[0117] 507. The first cache node sends the first origin request to the first tunnel node.

[0118] Origin connection reuse phase: 508. The first tunnel node checks the connection pool of the first worker thread.

[0119] If a corresponding origin connection for the first domain exists in the connection pool, proceed to step 509; if no corresponding origin connection for the first domain exists in the connection pool, proceed to step 510.

[0120] 509. Determine to reuse the source connection.

[0121] 510. The first tunnel node interacts with the source station to establish a new back-source connection.

[0122] 511. The first tunnel node adds the back-to-source connection to the connection pool of the first worker thread.

[0123] Source Response Phase: 512. The first tunnel node sends the first back-to-source request to the source station through the back-to-source connection.

[0124] 513. The first tunnel node receives the first back-source response from the source station through the back-source connection.

[0125] The first origin response carries the resource requested in the first origin request.

[0126] 514. The first tunnel node sends the first source response to the first cache node.

[0127] The first worker thread of the first tunnel node sends the first origin response to the first cache node through the first tunnel.

[0128] 515. The first cache node sends the first resource response to the terminal device.

[0129] After receiving the first origin response, the first cache node parses the resource requested by the first resource request from the first origin response, generates the first resource response, and sends it to the terminal device.

[0130] Figure 6AThis is a schematic diagram of the origin retrieval method provided in this application embodiment. Referring to Figure 6, clients 1 to 4 send resource requests to the cache node, each carrying the same domain name, example.com, and are randomly assigned to one of four processes. For example, client 1's resource request is assigned to process A, client 2's request is assigned to process B, client 3's request is assigned to process C, and client 4's request is assigned to process D. The cache node does not locally store resources related to example.com, requiring origin retrieval.

[0131] In the four processes, each process establishes a first tunnel with the first tunnel node. This first tunnel is bound to a first hash value, such as the hash value of the domain name example.com, which is assigned to the first worker thread of the first tunnel node. When a backhaul to the origin is needed, each process sends a first backhaul request to the first tunnel node through its first tunnel. Upon receiving the first backhaul request, the first tunnel node checks the connection pool of its first worker thread. If a backhaul connection for the domain name example.com exists in the connection pool, all four first backhaul requests reuse that connection. If no backhaul connection exists, a new backhaul connection is created, and all four first backhaul requests reuse this new connection. Clearly, even first backhaul requests from different processes use the same first worker thread for unified backhaul. Furthermore, these first backhaul requests carry the same domain name; therefore, they ultimately use the same backhaul connection.

[0132] Figure 6B yes Figure 6A A schematic diagram showing the distribution of the source-return connections. Please refer to... Figure 6A and Figure 6B When four clients request resources from the same domain, even if the four resource requests are randomly assigned to four processes, each process transmits its first origin pull request to the first tunnel node through the first tunnel between itself and the first tunnel node. The first tunnel node then uses its first worker thread to perform a unified origin pull for these four requests. Moreover, since these first origin pull requests carry the same domain name, there is no need to establish four origin pull connections between the first tunnel node and the origin server. Instead, the four first origin pull requests are aggregated into a single origin pull connection, achieving a 75% reuse rate for the origin pull connection. This avoids wasting cache node resources and significantly reduces the load on the origin server.

[0133] Table 1 index Traditional solution This application proposal Improvement effect Origin connection count 4 1 item Reduced by 75% Reuse rate 0% 75% Increase by 75% Connection overhead 4 times 1x Reduced by 75% Resource consumption high Low Reduced by 75% Table 1 lists the above. Figure 1A and Figure 6AThe comparison table is shown in Table 1. Taking four first-origin requests as an example, when using the tunneling scheme of this application, the reuse rate of the origin connection is as high as 75%, and the connection overhead and resource consumption are greatly reduced.

[0134] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0135] Figure 7 This is a schematic diagram of the first source return device provided in the embodiments of this application. The first source return device 700 is integrated on the first tunnel node and includes: a transceiver module 71 and a processing module 72.

[0136] The transceiver module 71 is used to receive a first origin request from a first process of a first cache node through a first tunnel. The first origin request carries a first domain name. The first tunnel is a tunnel between the first process and the first tunnel node. The first tunnel is bound to a first hash value. The first hash value is assigned to a first worker thread of the first tunnel node. The hash value of the first domain name is the first hash value. Processing module 72 is used to reuse the origin connection corresponding to the first domain name to return the first origin request when there is an origin connection corresponding to the first domain name in the connection pool of the first worker thread. The origin connection is used to connect the first tunnel node and the origin station.

[0137] In one feasible implementation, before the transceiver module 71 receives the first origin request from the first process of the first cache node through the first tunnel, it is also used to receive the target message from the first process of the first cache node, the target message carrying the first hash value; The processing module 72 is further configured to allocate the first working thread to the first hash value and establish the first tunnel between the first process and the first tunnel node according to the target message.

[0138] In one feasible implementation, during the process of the processing module 72 allocating the first worker thread to the first hash value, the number of concurrent tunnels is determined. The concurrent tunnels are tunnels that the first worker thread has currently established, and the concurrent tunnels are bound to the first hash value. When the number of concurrent tunnels is less than a preset threshold, the first worker thread is allocated to the first hash value.

[0139] In one feasible implementation, the processing module 72 is further configured to allocate a second working thread to the first hash value when the number of concurrent tunnels is greater than or equal to a preset threshold, wherein the second working thread is the first working thread in the sequence list after the first working thread.

[0140] In one feasible implementation, the transceiver module 71 is further configured to receive a second origin request from a first process of the first cache node through the first tunnel, the second origin request carrying a second domain name, the second hash value of the second domain name being the same as the first hash value; when there is an origin connection corresponding to the second domain name in the connection pool of the first worker thread, the origin connection corresponding to the second domain name is reused to return the second origin request.

[0141] In one feasible implementation, the transceiver module 71 is further configured to receive a third origin request from a second process of the first cache node through a second tunnel, the third origin request carrying a third domain name, the second tunnel being a tunnel between the second process and the first tunnel node, and the third hash value of the third domain name being the same as the first hash value. The processing module 72 is further configured to reuse the origin connection corresponding to the third domain name to return the third origin request when there is an origin connection corresponding to the third domain name in the connection pool of the first worker thread.

[0142] In one feasible implementation, the transceiver module 72 is further configured to receive a fourth origin request from a second tunnel node, wherein the second tunnel node is a tunnel node deployed on the same machine as the second cache node, the fourth origin request is an origin request sent by the process of the second cache node to the second tunnel node, the fourth origin request carries a fourth domain name, and the fourth hash value of the fourth domain name is the same as the first hash value. The processing module 72 is further configured to reuse the origin connection corresponding to the fourth domain name to return the first origin request when there is an origin connection corresponding to the fourth domain name in the connection pool of the first worker thread.

[0143] The first return-to-source device provided in this application embodiment can perform the actions of the first tunnel node in the above embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0144] Figure 8 This is a schematic diagram of a second source return device provided in an embodiment of this application. The second source return device 800 is integrated on a first cache node and includes a processing module 81 and a transceiver module 82.

[0145] Processing module 81 is used to allocate a first resource request from a terminal device to a first process of the first cache node, wherein the first resource request carries a first domain name; The transceiver module 82 is used to send a first origin request to a first tunnel node through a first tunnel when the first cache node does not cache the resource requested by the first resource request locally, so that the first worker thread of the first tunnel node processes the first origin request. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread, and the hash value of the first domain name is the first hash value.

[0146] In one feasible implementation, when the first cache node does not cache the resource requested by the resource request locally, before the transceiver module 82 sends the first origin request to the first tunnel node through the first tunnel, the processing module 81 is further configured to determine whether there is a first tunnel bound to the first hash value between the first process and the first tunnel node. The transceiver module 82 is further configured to send a target message to the first tunnel node when there is no first tunnel between the first process and the first tunnel node, the target message carrying the first hash value of the first domain name; The processing module 81 is further configured to establish the first tunnel between the first process and the first tunnel node based on the target message.

[0147] In one feasible implementation, the processing module 81 is further configured to allocate a second resource request from the terminal device to a first process of the first cache node, wherein the second resource request carries a second domain name and the second hash value of the second domain name is the same as the first hash value; The transceiver module 82 is further configured to send a second origin request to the first tunnel node through the first tunnel when the first cache node does not cache the resource requested by the second resource request locally.

[0148] In one feasible implementation, the processing module 81 is further configured to allocate a third resource request from the terminal device to a second process of the first cache node; The transceiver module 82 is further configured to send a third origin request to the first tunnel node through a second tunnel when the first cache node does not cache the resource requested by the third resource request locally. The second tunnel is a tunnel between the second process of the first cache node and the first tunnel node, and the third hash value of the third domain name is the same as the first hash value.

[0149] The second source return device provided in this application embodiment can perform the actions of the first cache node in the above embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0150] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. A first cache node and a first tunnel node are deployed on this electronic device. Figure 9 As shown, the electronic device 900 includes: Processor 91 and memory 92; The memory 92 stores computer instructions; The processor 91 executes the computer instructions stored in the memory 92, causing the processor 91 to execute the back-to-source method implemented by the first tunnel node as described above; or, causing the processor 91 to execute the back-to-source method implemented by the first cache node as described above.

[0151] The specific implementation process of processor 91 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0152] Optionally, the electronic device 900 also includes a communication component 93. The processor 91, memory 92, and communication component 93 can be connected via a bus 94.

[0153] This application embodiment also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, are used to implement the above-mentioned electronic device to perform the above-mentioned first tunnel node's back-to-origin method; or to cause the electronic device to perform the above-mentioned first cache node's back-to-origin method.

[0154] This application also provides a computer program product comprising a computer program that, when executed by a processor, implements the above-mentioned electronic device executing the above-mentioned first tunnel node's back-to-origin method; or, causes the electronic device to execute the above-mentioned first cache node's back-to-origin method.

[0155] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0156] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A source traversal method, characterized in that, Applied to the first tunnel node, the method includes: The first origin request is received from the first process of the first cache node through the first tunnel. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node. The first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread of the first tunnel node. The hash value of the first domain name is the first hash value. When the first worker thread has a back-to-origin connection corresponding to the first domain name in its connection pool, it reuses the back-to-origin connection corresponding to the first domain name to back-to-origin the first back-to-origin request. The back-to-origin connection is used to connect the first tunnel node and the origin station.

2. The method according to claim 1, characterized in that, Before receiving the first origin request from the first process of the first cache node through the first tunnel, the method further includes: Receive a target message from a first process of the first cache node, the target message carrying the first hash value; Assign the first worker thread to the first hash value; The first tunnel is established between the first process and the first tunnel node according to the target message.

3. The method according to claim 2, characterized in that, The step of allocating the first worker thread to the first hash value includes: The number of concurrent tunnels is determined, wherein the concurrent tunnels are the tunnels currently established by the first worker thread, and the concurrent tunnels are bound to the first hash value; When the number of concurrent tunnels is less than a preset threshold, the first worker thread is allocated to the first hash value.

4. The method according to claim 3, characterized in that, Also includes: When the number of concurrent tunnels is greater than or equal to a preset threshold, a second worker thread is allocated to the first hash value. The second worker thread is the first worker thread in the sequence list after the first worker thread.

5. The method according to any one of claims 1 to 4, characterized in that, Also includes: The first process receives a second origin request from the first cache node through the first tunnel. The second origin request carries a second domain name, and the second hash value of the second domain name is the same as the first hash value. When the connection pool of the first worker thread contains a connection to the origin server corresponding to the second domain name, the connection to the origin server corresponding to the second domain name is reused to request the second origin server request.

6. The method according to any one of claims 1 to 4, characterized in that, Also includes: The third origin request is received from the second process of the first cache node through the second tunnel. The third origin request carries a third domain name. The second tunnel is a tunnel between the second process and the first tunnel node. The third hash value of the third domain name is the same as the first hash value. When the connection pool of the first worker thread contains a back-to-origin connection corresponding to the third domain name, the back-to-origin connection corresponding to the third domain name is reused to back-to-origin the third back-to-origin request.

7. The method according to any one of claims 1 to 3, characterized in that, Also includes: Receive a fourth origin pull request from the second tunnel node, which is a tunnel node deployed on the same machine as the second cache node. The fourth origin pull request is an origin pull request sent by the process of the second cache node to the second tunnel node. The fourth origin pull request carries a fourth domain name, and the fourth hash value of the fourth domain name is the same as the first hash value. When the connection pool of the first worker thread contains a back-to-origin connection corresponding to the fourth domain name, the back-to-origin connection corresponding to the fourth domain name is reused to back-to-origin the first back-to-origin request.

8. A source traversal method, characterized in that, Applied to the first cache node, the method includes: The first resource request from the terminal device is assigned to the first process of the first cache node, and the first resource request carries the first domain name; When the first cache node does not cache the resource requested by the first resource request locally, it sends a first origin request to the first tunnel node through the first tunnel, so that the first worker thread of the first tunnel node processes the first origin request. The first origin request carries the first domain name. The first tunnel is a tunnel between the first process and the first tunnel node, and the first tunnel is bound to a first hash value. The first hash value is assigned to the first worker thread, and the hash value of the first domain name is the first hash value.

9. The method according to claim 8, characterized in that, Before sending the first origin request to the first tunnel node through the first tunnel when the first cache node does not locally cache the resource requested by the resource request, the method further includes: Determine whether a first tunnel bound to the first hash value exists between the first process and the first tunnel node; When there is no first tunnel between the first process and the first tunnel node, a target message is sent to the first tunnel node, the target message carrying the first hash value of the first domain name; The first tunnel is established between the first process and the first tunnel node according to the target message.

10. The method according to claim 8, characterized in that, Also includes: A second resource request from a terminal device is assigned to a first process of the first cache node. The second resource request carries a second domain name, and the second hash value of the second domain name is the same as the first hash value. When the first cache node does not cache the resource requested by the second resource request locally, it sends a second origin request to the first tunnel node through the first tunnel.

11. The method according to any one of claims 8 to 10, characterized in that, Also includes: The third resource request from the terminal device is assigned to the second process of the first cache node; When the first cache node does not cache the resource requested by the third resource request locally, it sends a third origin request to the first tunnel node through the second tunnel. The second tunnel is a tunnel between the second process of the first cache node and the first tunnel node. The third hash value of the third domain name is the same as the first hash value.

12. An electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it causes the electronic device to implement the method as described in any one of claims 1 to 11.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 11.