CDN cache replacement method
By using a fixed-size memory table and hash index in the CDN cache, the problem of low disk IO efficiency in the existing technology is solved, efficient cache replacement is achieved, and the disk IO efficiency and cache hit rate are improved.
Patent Information
- Application Number
- CN202411252239.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-09-09
AI Technical Summary
Existing CDN cache replacement algorithms such as LRU and MRU fail to effectively consider access frequency, resulting in frequent cache replacement, resulting in low disk IO efficiency and large traffic pulled to the upper-level node.
Using a memory table with a fixed size space, resources are stored in the memory table through slicing and hash indexes, and fast search operations are used for insertion and update to achieve hotspot updates, reduce direct interaction with the disk, and improve disk IO efficiency.
By appending new resources to the memory, the disk writing speed is reduced, batch sequential reading and writing is realized, the disk IO efficiency is improved, and the cache hit rate and access speed are improved through the hotspot update mechanism.
Smart Images

Figure CN118760631A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network transmission technology, and specifically relates to a CDN cache replacement method. Background Technology
[0002] A CDN (Content Delivery Network) is a distributed network system designed to improve the speed and reliability of content distribution by caching and distributing content across multiple geographically dispersed servers. CDNs are widely used to accelerate content delivery for websites, streaming media, online games, and other internet services. When a user initiates a network request, they first access the nearest CDN node. If the resource is available, it can be obtained with lower network latency; otherwise, a further request is made to the central network node. However, each CDN node cannot store all resources; it can only select critical resources to meet the needs of the largest number of users. Therefore, when a CDN node returns a resource to a user, it needs to consider whether to retain the resource for future requests. The selection of old and new resources is the CDN's cache replacement process. Currently, representative cache replacement algorithms include LRU (Least Recently Used) and MRU (Most Recently Used). These two methods are simple in principle and implementation, and therefore have become common strategies.
[0003] LRU and MRU do not take into account access frequency and other factors, which can easily lead to frequent cache replacements, resulting in excessive disk I / O and excessive traffic being pulled to the next higher level node. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a CDN cache replacement method to solve the problem of low disk I / O efficiency in the prior art.
[0005] On the one hand, the invention provides the following technical solution: a CDN cache replacement method, the method comprising: creating a memory table of fixed size, wherein the memory table is an empty table and its quantity is one; If the current CDN node obtains the first resource from the previous CDN node, the obtained first resource is sliced into several fragments, the first index corresponding to each fragment is calculated, and the fragment is stored in the memory table based on the first index. When the current CDN node responds to a user request and returns a second resource, it calculates the second index of the second resource that needs to be returned, and checks whether the memory table with inserted fragments exists and the second resource needs to be returned based on the second index. If a second resource that needs to be returned is found in the memory table where the fragment is stored, then the second resource that needs to be returned is returned and a hotspot update is performed; If the fragment is not found in the memory table where it is stored, the second resource needs to be returned. Then, the step of obtaining the first resource from the previous CDN node is re-executed.
[0006] Compared to existing technologies, the beneficial effects of this application are as follows: By calculating the first index corresponding to each fragment and storing the fragment in the memory table based on the first index, when a new resource is acquired, the disk data is not directly updated, but rather appended to memory, greatly accelerating the write speed. Furthermore, compared to LRU, MRU, and their variants which directly operate on the disk, this application only performs batch sequential reads and writes on the disk, thereby improving disk I / O efficiency. The step of returning to the second resource and performing a hotspot update ensures that frequently read data is always in a lower-level table, greatly improving the hit rate and access speed.
[0007] Furthermore, the step of calculating the first index corresponding to each of the segments includes: Calculate the hash function value for each of the segments and use the hash function value as the first index of the segment. If the two first indices are different, then the segments corresponding to the two indices are also different.
[0008] Furthermore, the step of storing the fragment into the memory table based on the first index includes: Use a fast lookup operation to check if the first index exists in the memory table; If the first index exists in the memory table, then update the third resource corresponding to the first index; If the first index does not exist in the memory table, the segment corresponding to the first index is inserted into the memory table.
[0009] Furthermore, after the step of inserting the fragment corresponding to the first index into the memory table, the method further includes: Real-time determination of whether the memory table has remaining storage space; if the memory table has no remaining storage space. Then the memory table is persisted to form a persistent table, and a new memory table is created. The remaining fragments are then stored in a new memory table, and the step of determining in real time whether there is still storage space left in the memory table is repeated until all fragments are stored.
[0010] Furthermore, after the step of storing all said fragments, the method further includes: Determine whether the current number of persistent tables has reached a first threshold. If the current number of persistent tables has reached the first threshold; Then, based on the index value corresponding to the persistent table, all the current persistent tables are merged in multiple ways to form a merged table. When the index values of two persistent tables are the same, the data with the latest timestamp is taken for merging. Determine whether the current number of merged tables has reached the second threshold. If the current number of merged tables has reached the second threshold; Then all the current persistent tables are merged to form a merged layer, and multiple layers of space are created on the hard disk, and the merged layer is stored in the multiple layers of space; If the storage capacity of the multi-layer space reaches its limit, then the data corresponding to the highest layer of the multi-layer space will be cleaned up.
[0011] Furthermore, the step of performing a hotspot update includes: Repeat the steps described above when the current CDN node obtains the first resource from the previous CDN node, insert a triple, and mark the data stored in the triple as an address in the extra data of the triple, and mark the triple as referenced in the extra data of the triple corresponding to the address, wherein the index of the triple is the second index, and the value of the triple data is the address of the second resource.
[0012] Furthermore, after the step of returning to the second resource if it is not found in the memory table storing the fragment, the method further includes: Determine whether the address of the second resource to be returned is the address obtained in the hotspot update step; if the address of the second resource to be returned is the address obtained in the hotspot update step. Then, determine whether the address is valid. If the address is invalid, re-execute the step of obtaining the first resource from the previous CDN node.
[0013] Secondly, the invention provides the following technical solution: a CDN cache replacement system, the system comprising: A creation module is used to create a memory table of fixed size, wherein the memory table is empty and there is only one such table; The storage module is used to slice the first resource obtained by the current CDN node from the previous CDN node to obtain several fragments, calculate the first index corresponding to each fragment, and store the fragment in the memory table based on the first index. The lookup module is used to calculate the second index of the second resource to be returned when the current CDN node responds to a user request and returns the second resource, and to search the memory table storing fragments based on the second index to see if the second resource to be returned exists. The update module is used to return the second resource that needs to be returned and perform a hotspot update if the memory table storing fragments is found. The execution module is used to re-execute the step of obtaining the first resource from the previous CDN node if the current CDN node does not find the resource in the memory table where the fragment is stored and a second resource needs to be returned.
[0014] Thirdly, the invention provides the following technical solution: a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the CDN cache replacement method as described above.
[0015] Fourthly, the invention provides the following technical solution: a storage medium storing a computer program, which, when executed by a processor, implements the CDN cache replacement method described above. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart of the CDN cache replacement method provided in the first embodiment of the present invention; Figure 2 This is a structural block diagram of the CDN cache replacement system provided in the second embodiment of the present invention; Figure 3 This is a schematic diagram of the hardware structure of a computer provided in the third embodiment of the present invention.
[0018] The embodiments of the present invention will be further described below with reference to the accompanying drawings. Detailed Implementation
[0019] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain embodiments of the present invention, and should not be construed as limiting the present invention.
[0020] In the description of the embodiments of the present invention, it should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the present invention.
[0021] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of the present invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0022] Example 1 In the first embodiment of the present invention, please refer to Figure 1 A CDN cache replacement method includes the following steps S01 to S05: S01, Create a memory table with a fixed size, wherein the memory table is empty and there is only one such table; In this embodiment, a fixed-size space is allocated in the CDN's memory as an empty table, called table l0, and only one table l0 is allowed to exist.
[0023] S02, if the current CDN node obtains the first resource from the previous CDN node, the obtained first resource is sliced to obtain several fragments, the first index corresponding to each fragment is calculated, and the fragment is stored in the memory table based on the first index; Specifically, the step of calculating the first index corresponding to each of the segments includes: Calculate the hash function value for each of the segments and use the hash function value as the first index of the segment. If the two first indices are different, then the segments corresponding to the two indices are also different.
[0024] In this embodiment, when a CDN node retrieves resources from a parent CDN node, the retrieved resources are sliced into fragments of size m. An index is created for each fragment, and all fragments are stored in table l0. The indexes are created by calculating the hash function value of the fragment; different indices indicate different fragments.
[0025] Specifically, the step of storing the fragment into the memory table based on the first index includes: S21, use a fast lookup operation to check if the first index exists in the memory table; S22, if the first index exists in the memory table, then update the third resource corresponding to the first index; S23, if the first index does not exist in the memory table, insert the segment corresponding to the first index into the memory table.
[0026] In this embodiment, the storage method is to use the table's fast lookup operation to find the fragment index. If the index already exists in the table, the data corresponding to the index is directly updated. Otherwise, the fragment corresponding to the index is inserted into the table according to the position returned by the fast lookup operation.
[0027] After the step of inserting the fragment corresponding to the first index into the memory table, the method further includes: S24, determine in real time whether the memory table has any remaining storage space; if the memory table has no remaining storage space. S25, then persist the memory table to form a persistent table, and create a new memory table; S26, continue to store the remaining fragments into a new memory table, and repeat the step of determining in real time whether there is still storage space left in the memory table until all fragments are stored.
[0028] In this embodiment, when there is no space to store in table l0, table l0 is persisted to the hard disk. The table persisted to the hard disk from table l0 is called table l11. At the same time, a new empty table l0 is created, and the remaining fragments are stored in the new table l0.
[0029] Specifically, after the step of storing all the fragments, the method further includes: S27, determine whether the current number of persistent tables has reached the first threshold; if the current number of persistent tables has reached the first threshold. S28, then based on the index value corresponding to the persistent table, all the current persistent tables are merged in multiple ways to form a merged table. When the index values of two persistent tables are the same, the data with the latest timestamp is taken for merging. S29, determine whether the current number of merged tables has reached the second threshold; if the current number of merged tables has reached the second threshold. S30, then merge all the current persistent tables to form a merge layer, create a multi-layer space on the hard disk, and store the merge layer in the multi-layer space; S31, if the storage capacity of the multi-layer space reaches its limit, then the data corresponding to the highest layer of the multi-layer space is cleaned up.
[0030] In this embodiment, multiple 11 tables are allowed, with the maximum number denoted as . When the limit for L1 tables is reached, all L1 tables are merged to form a new table called the L2 table (merged table). Multiple L2 tables are allowed, with the maximum number denoted as L2. This table structure can be multi-level, such as 13, 14...1, depending on the needs and disk space. n When the maximum number of levels is reached, the data at the highest level is cleaned up. The merging process involves multi-way merging based on index values, combining multiple tables into one. When encountering identical index values, the data with the latest timestamp is used.
[0031] S03, when the current CDN node responds to the user's request to return the second resource, calculate the second index of the second resource that needs to be returned, and check whether the memory table with inserted fragments exists and the second resource needs to be returned based on the second index.
[0032] S04, if a second resource that needs to be returned is found in the memory table storing the fragment, then the second resource that needs to be returned is returned and a hotspot update is performed.
[0033] Specifically, the steps for performing a hotspot update include: Repeat the steps described when the current CDN node obtains the first resource from the previous CDN node, insert a triple, and mark the data stored in the triple as an address in the extra data of the triple. Also, mark the triple as referenced in the extra data of the triple corresponding to the address. The index of the triple is the second index, and the value of the triple data is the address of the second resource. In this implementation, the hotspot update step is as follows: Step S02 is executed once, inserting a triplet. The index of the triplet is the index of the resource fragment found in step S03, the value of the data is the address of the found resource, and the additional data marks that the data stored in the triplet is an address, and the additional data of the triplet corresponding to that address marks that the triplet is referenced.
[0034] S05, if the fragment is not found in the memory table that stores the fragment and the second resource needs to be returned, then the step of obtaining the first resource from the previous CDN node is re-executed.
[0035] Specifically, after the step of returning to the second resource if it is not found in the memory table storing the fragment, the method further includes: Determine whether the address of the second resource to be returned is the address obtained in the hotspot update step; if the address of the second resource to be returned is the address obtained in the hotspot update step. Then, determine whether the address is valid. If the address is invalid, re-execute the step of obtaining the first resource from the previous CDN node.
[0036] In this embodiment, when a CDN node responds to a user request and returns data, it calculates the index of the data to be returned and searches sequentially according to the index. surface, surface…… If the table is found, the resource is returned and a hotspot update is performed. If it is not found, the process jumps to step S02 to pull the resource from the next higher-level CDN node.
[0037] In this embodiment, during the search in step S03, if the data is found to be an address that is frequently updated, then the search for that address is further conducted. If the address is invalid (e.g., it was cleaned up in step S31), then it is considered that no data was found, and the process jumps to step S02 to pull resources from the next higher-level CDN node. When data cleanup is triggered in step S31, if the data to be cleaned is referenced, the cleaned data will be copied to the referenced data.
[0038] In this embodiment, a CDN cache replacement method can be applied to live streaming. The broadcaster uploads live segments to a live streaming platform, which then distributes these segments to CDN nodes located across the country. This distribution process can be proactive, where the platform actively sends the live segments to various CDN nodes; or passive, where a viewer accesses the broadcaster's live room, undergoes DNS resolution, and is redirected to the CDN node closest to the viewer. Upon receiving the viewer's access request, the CDN node finds it does not have the corresponding live segment resource and initiates a resource request to its superior CDN node, escalating the process up the hierarchy until it reaches the live streaming platform. This invention is deployed on CDN nodes, caching resources when they enter a CDN node (distributed by a superior CDN node) or leave a CDN node (in response to a viewer's access request).
[0039] One core component of a CDN cache replacement method is a data structure called a "table." The table is a sequence of triples (index, extra data, data) sorted by index. The extra data stores additional information, such as timestamps. It provides a fast lookup operation (complexity of log(n)), which returns the position of a triple corresponding to an index, or the position of a non-existent triple. Each triple is allocated the same amount of space. In practice, this table can use a "skip list" data structure.
[0040] In summary, a CDN cache replacement method has the following effects: When new resources are acquired, the data is not updated directly on the disk, but appended to memory, which greatly accelerates the writing speed. Compared with LRU, MRU and their variants, which directly operate on the disk (which is usually a random read and write process), the disk operation of this invention is only a batch of sequential read and write (persisting a new table simply stores the data on the hard disk without searching for a specific location, and sequential read and write is much faster than random read and write), and the disk I / O performance is also excellent.
[0041] Regarding cache hit rate, the existence of the hotspot update mechanism ensures that frequently read data is always in lower-level tables, greatly improving the hit rate and access speed.
[0042] Regarding resource lookups, because the tables are designed with a sequential structure, fast lookup methods can be used within the tables. Furthermore, when searching deeper levels of tables on disk, searches can be performed between tables from newest to oldest timestamps. Since most data is rarely accessed in practice, with only a small portion being accessed frequently, most searches are performed in memory (hot data is mostly concentrated in...). (Table), thus providing excellent search efficiency.
[0043] In this invention, due to the append-only nature of the write operation, the two write operations are completely unrelated and do not involve complex mechanisms such as data locks, thus supporting efficient concurrent access. When a fragment is written to the next level, the merging and creation of new tables in the next level are unrelated to the lookup, read, and write operations in the previous level. Therefore, it has the potential to be designed as a multi-threaded or distributed system with certain scalability and acceleration capabilities.
[0044] Example 2 like Figure 2 As shown, a second embodiment of the present invention provides a CDN cache replacement system, the system comprising: Module 10 is used to create a memory table of fixed size, wherein the memory table is empty and there is only one such table. The storage module 20 is used to slice the first resource obtained by the current CDN node from the previous CDN node to obtain several fragments, calculate the first index corresponding to each fragment, and store the fragment in the memory table based on the first index. The lookup module 30 is used to calculate the second index of the second resource to be returned when the current CDN node responds to a user request and returns the second resource, and to search the memory table storing fragments based on the second index to see if the second resource to be returned exists. The update module 40 is used to return the second resource that needs to be returned and perform a hotspot update if the second resource that needs to be returned is found in the memory table where the fragments are stored. The execution module 50 is used to re-execute the step of obtaining the first resource from the previous CDN node if the second resource is not found in the memory table where the fragment is stored.
[0045] The CDN cache replacement system provided in this embodiment of the invention has the same implementation principle and technical effects as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the system embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0046] Example 3 like Figure 3 As shown, in the third embodiment of the present invention, the present invention provides the following technical solution: a computer, including a memory 202, a processor 201, and a computer program stored on the memory 202 and executable on the processor 201, wherein the processor 201 executes the computer program to implement the CDN cache replacement method as described above.
[0047] Specifically, the processor 201 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0048] Memory 202 may include mass storage for resources or instructions. For example, and not limitingly, memory 202 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), flash memory, an optical disk drive, a magneto-optical disk drive, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 202 may include removable or non-removable (or fixed) media. Where appropriate, memory 202 may be internal or external to the resource processing device. In a particular embodiment, memory 202 is non-volatile memory. In a particular embodiment, memory 202 includes read-only memory (ROM) and random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable read-only memory (PROM), an erasable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), an electrically alterable read-only memory (EAROM), or flash memory, or a combination of two or more of these. Where appropriate, the RAM can be Static Random-Access Memory (SRAM) or Dynamic Random-Access Memory (DRAM). DRAM can be Fast Page Mode Dynamic Random Access Memory (FPMDRAM), Extended Date Out Dynamic Random Access Memory (EDODRAM), Synchronous Dynamic Random-Access Memory (SDRAM), etc.
[0049] The memory 202 can be used to store or cache various resource files that need to be processed and / or communicated, as well as possible computer program instructions executed by the processor 201.
[0050] The processor 201 implements the CDN cache replacement method described above by reading and executing computer program instructions stored in the memory 202.
[0051] In some embodiments, the computer may further include a communication interface 203 and a bus 200. For example, Figure 3 As shown, the processor 201, memory 202, and communication interface 203 are connected through bus 200 and complete communication with each other.
[0052] The communication interface 203 is used to enable communication between the various modules, devices, units, and / or equipment in the embodiments of this application. The communication interface 203 can also enable resource communication with other components such as external devices, image / resource acquisition devices, resource libraries, external storage, and image / resource processing workstations.
[0053] Bus 200 includes hardware, software, or both, that couples computer components together. Bus 200 includes, but is not limited to, at least one of the following: Data Bus, Address Bus, Control Bus, Expansion Bus, and Local Bus. For example, and not as a limitation, bus 200 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 200 may include one or more buses. Although specific buses are described and illustrated in the embodiments of this application, this application considers any suitable bus or interconnection.
[0054] Example 4 In the fourth embodiment of the present invention, in conjunction with the above-described CDN cache replacement method, the present invention provides the following technical solution: a storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the above-described CDN cache replacement method.
[0055] Those skilled in the art will understand that resources in the flowchart, or logic and / or steps otherwise described herein, such as a sequenced resource table of executable instructions for implementing logical functions, can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from or in conjunction with such an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0056] More specific examples of readable media (a non-exhaustive list of resources) include: electrical connections (electronic devices) with one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0057] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on resource signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0058] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0059] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A CDN cache replacement method, characterized in that: The method comprises: Create a memory table with a fixed size space, wherein the memory table is an empty table and the number of the memory table is one; If the current CDN node obtains the first resource from the previous CDN node, the obtained first resource is sliced to obtain a plurality of segments, a first index corresponding to each of the segments is calculated, and the segments are stored in the memory table based on the first index; When the current CDN node returns the second resource in response to the user request, the second index of the second resource to be returned is calculated, and the second index is searched to determine whether the memory table storing the fragments contains the second resource to be returned according to the second index; If the second resource to be returned is found in the memory table storing the fragments, the second resource to be returned is returned and a hotspot update is performed; If the second resource to be returned is not found in the memory table storing the segments, the step of if the current CDN node obtains the first resource from the previous CDN node is re-executed.
2. The CDN cache replacement method according to claim 1, characterized in that: The step of calculating the first index corresponding to each of the fragments comprises: A hash function value of each of the fragments is calculated, and the hash function value is used as a first index of the fragment, wherein if two first indexes are different, the fragments corresponding to the two are also different.
3. The CDN cache replacement method according to claim 1, characterized in that: The step of storing the fragment in the memory table based on the first index comprises: Using a quick search operation to find out whether the first index exists in the memory table; If the first index exists in the memory table, updating the third resource corresponding to the first index; If the first index does not exist in the memory table, insert the fragment corresponding to the first index into the memory table.
4. The CDN cache replacement method according to claim 3, characterized in that: After the step of inserting the fragment corresponding to the first index into the memory table, the method further includes: Determine in real time whether the memory table has any storage space left, if the memory table has no storage space left; The memory table is persisted to form a persistent table, and a new memory table is created; The remaining segments continue to be stored in the new memory table, and the step of determining in real time whether there is any storage space left in the memory table is repeated until all the segments are stored.
5. The CDN cache replacement method according to claim 4, characterized in that: After the step of storing all the fragments, the method further comprises: Determine whether the number of the persistent tables currently reaches a first threshold, if the number of the persistent tables currently reaches the first threshold; Based on the index value corresponding to the persistent table, all the current persistent tables are multi-way merged to form a merged table, wherein when the index values of two persistent tables are the same, the data with the latest timestamp is taken for merging; Determine whether the current number of the merged tables reaches a second threshold, if the current number of the merged tables reaches the second threshold; Then all the current persistent tables are merged to form a merged layer, a multi-layer space is created in the hard disk, and the merged layer is stored in the multi-layer space; If the storage of the multi-layer space reaches an upper limit, the data corresponding to the highest layer of the multi-layer space is cleared.
6. The CDN cache replacement method according to claim 1, characterized in that: The steps of performing a hotspot update include: Repeat the steps when the current CDN node obtains the first resource from the previous CDN node, insert a triplet, and mark in the additional data of the triplet that the data stored in the triplet is an address, and mark the triplet as referenced in the additional data of the triplet corresponding to the address, wherein the index of the triplet is the second index, and the value of the triplet data is the address of the second resource.
7. The CDN cache replacement method according to claim 1, characterized in that: After the step of returning the second resource if the memory table storing the fragments does not find the second resource, the method further includes: Determine whether the address of the second resource to be returned is the address obtained by performing a hotspot update step, if the address of the second resource to be returned is the address obtained by performing a hotspot update step; It is then determined whether the address is valid. If the address is invalid, the step of re-executing the step of obtaining the first resource from the previous CDN node by the current CDN node is performed.
8. A CDN cache replacement system, characterized in that: The system comprises: A creation module, used for creating a memory table of a fixed-size space, wherein the memory table is an empty table and the number of the memory table is one; a storage module, configured to slice the acquired first resource to obtain a plurality of segments, calculate a first index corresponding to each segment, and store the segment in the memory table based on the first index when the current CDN node acquires the first resource from the previous CDN node; a search module, configured to calculate a second index of the second resource to be returned when the current CDN node returns the second resource in response to a user request, and search the memory table storing the fragments according to the second index to see whether the second resource to be returned exists; An updating module, configured to return the second resource to be returned and perform a hotspot update if the second resource to be returned is found in the memory table storing the fragments; The execution module is used to re-execute the step of obtaining the first resource from the previous CDN node if the second resource to be returned is not found in the memory table storing the fragments.
9. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the CDN cache replacement method according to any one of claims 1 to 7 is implemented.
10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the CDN cache replacement method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for operating multiple content distribution network (CDN) service processes in single device
CN103024018A
Resource storage indexing device and method in CDN system
CN104951480A
Data query method and terminal device
CN109726219A
Data processing method and system based on multi-level cache
CN113672524A
Efficient CDN fragment refreshing method
CN113691581A
