Akamai's algorithmic research in content distribution networks (translation summary)

Source: Internet
Author: User

BLOOM FILTERS

The research of Bloom filters is mainly used in two scenarios in Akamai's CDN: 1) index management optimization; 2) content filtering.

Bloom filters is a variant of the hash algorithm, has excellent spatial efficiency (using bit arrays) and time efficiency (the insertion time complexity is constant), but there is a certain error rate. Intuitively, the bloom algorithm resembles a hash set, which is used to determine whether an element (key) is in a set. Unlike the general hash set, the algorithm does not need to store the value of the key, and for each key, it requires only k bits, each storing a flag to determine if the key is in the collection. The basic algorithm is as follows:

1) First you need k hash function, each function can hash key into 1 integers

2) When initializing, an array of length n bits is required and each bit is initialized to 0

3) When a key is added to a set, the K hash value is computed with k hash function, and the corresponding bit position in the array is 1.

4) Determine whether a key is in the collection, with K hash function to calculate the K hash value, and query the corresponding bit in the array, if all bits are 1, think in the collection.

Through a series of mathematical proofs of Balabala, we can get the number k of the optimal hash function, the number of bits in the bit array m, and the number of the most element n of the storage:

Through a series of mathematical proofs of Balabala, we can get the positive error rate, the number of bits in the bit array, and the number of the most element n of the storage, as follows:

Based on these two formulas, parameter adjustments can be made to achieve the desired target. The main scenarios of Bloom filters are as follows:

1) index management optimization: Some cache system index query may be due to slow device access caused by slow query operation, you can use Bloom filters before the index query to build a layer of index cache to raise the index query speed, if Bloom filters cannot find the file, It is considered that the file does not exist, and if the file can be found in bloom filters, the index system is requested. In this scenario, because of the element deletion operation, Bloom filters cannot use a bit array, and each bit needs to be replaced with a numeric variable that is incremented when multiple files share one.

2) Content filtering: Akamai counts the number of Web file accesses in a server cluster two days, as you can see, in a total of 400 million or so files, 74% of the files have been accessed only once and 90% files have been accessed less than 4 times.

There is no need for a single-access file to be dropped, and for this type of file, disk IO and storage will be consumed, and more hot files may be squeezed out, thereby reducing the cache hit rate resulting in higher back-source bandwidth.

Based on this, Akamai implements the "Cache-on-second-hit rule." Algorithm, that is, the file is a second access to the disk, and the record whether there is a first access to use the algorithm is Bloom filters.

Since the number of files accessed on the CDN is approaching infinity, you can use two bloom filters alternately to record the first time the file is accessed, and when the first bloom filters has reached the upper limit that can be recorded, the second bloom filters is used, and if the second one reaches the upper limit, Then empty the first bloom filters re-use the first one, each time the query file has ever been accessed need to query two bloom filters.

After Akamai implemented this component and tested it in the test environment, the test environment cache hit rate increased from 74% to 83%, the amount of disk write data dropped by 44%, and the disk operation latency decreased by 24%.

Stable distribution Issues

The research on the problem of stable distribution is mainly used for global load balancing.

Two concepts can be abstracted from a network in a CDN.

1) The Map Unit,map unit contains two elements, the first element is a collection of user IPs, and the second element is the type of the map unit (such as video, web, etc.)

2) The minimum unit of server Cluster,akamai is cluster, and a cluster contains several servers. Global load balancing can be achieved by stable distribution of the map unit and server cluster.

Akamai has researched and expanded the Gale-shapley algorithm to address global load balancing issues. The standard Gale-shapley algorithm is proposed to solve the "stable marriage problem": to find the most suitable spouse for n males and n females. The basic idea of the algorithm is to mark all men as free men before losing them. And each man and every woman has a sort of ranking that marks the right opposite sex in the sort. When a free male is present, do the following:

(1) Every free man chooses one of the women who has not yet refused her the highest priority;

(2) Each woman will be pursuing her free male compared with his current boyfriend, choose one of the top ranking men as his boyfriend, even if free male than the current boyfriend, then abandon the ex-boyfriend, otherwise keep his boyfriend, refuse free male.

(3) If a man is abandoned by his girlfriend, he becomes a free man again.

The algorithm is extended based on the following points to match the map unit and server cluster, which is global load balancing.

(1) The number of map unit and server cluster is not equal. In a normal CDN scenario, the number of map unit is more than the number of server cluster.

(2) The column list can be incomplete. There is no need to create a map unit to order the performance score of all server cluster, just select the server cluster that the user group might be dispatched to and score the order.

(3) Each server cluster has an indeterminate amount of capacity. Estimate the capacity of the server cluster and let it serve multiple user groups.

With the expansion of the Gale-shapley algorithm as a framework, and then the resources of the machine refinement, a server cluster the resources of a machine can be specifically divided into two kinds: network resources and non-network resources (such as memory, CPU capacity, etc.). Network resource consumption is represented by BPS, and non-network resource consumption is expressed by FPS. Then you can use the following hierarchical resource tree to represent the resources of a machine:

Node A represents the machine's available network resource for 50bps,node B, which represents the 30FPS of non-network resources available for the machine, and the leaf node represents the maximum FPS that can be used for different request types.

If you receive a 20 unit video request at this time, each unit request consumes 0.25FPS and 1BPS, then the resources tree remaining resources as shown in the blue Word, Node A remaining 30bps,node B remaining Fps,node c remaining.

Suppose you receive a 26-unit Web request Next, Each request consumes 1FPS and 0.2BPS, with a total consumption of 26FPS and 6.2BPS, when the current machine's resources are found to be insufficient to withstand all Web requests, and the cluster and the map are judged based on the output of scoring (the component that Akamai uses to evaluate the service performance of the client and server) There is better performance between units, and if the result is more appropriate for the service of the new Web request, then the Gale-shapley algorithm will expel the 4 unit of old video request and accept the new Web request. This eviction can be done over and over again to achieve optimal allocation globally.

It is felt that this algorithm still has many challenges in specific implementation details.

Consistent Hash

The research of consistent hash is used to realize the local load balancing of Akamai's CDN. The sense of consistency hash should be inextricably linked to Akamai, as both are sourced from MIT, where a consistent hash of the proposed person worked at Akamai and so on.

When a user is assigned to a server cluster, the same file request can be hashed as much as possible through a consistent hash to a machine that has already cached the file in the cache. Therefore, the cache hit rate can be increased by the consistent hash to achieve the goal of improving performance and increasing resource availability.

About the most basic consistency hash algorithm on the web there are many explanations, the consistency hash solves the problem that when a cache down in a distributed system or a new cache may cause all the cache content to be re-shuffled. And the virtual nodes are introduced to optimize the results of the algorithm. There's a lot of stuff on the web, and it's not repeating. Here are some examples of Akamai's characterization of consistent hashing:

1) for hot files, in order to prevent the request pressure in the server group on the same machine, it is necessary to map a hotspot file to the K server for streaming, the more convenient way to map the file on the original hash machine and after the (k-1) machine. Different hot file collection in the consistency hash, need to change the arrangement of hash bucket, in order to prevent due to the hash value close to the different files mapped by the K machine most overlap, resulting in high machine load problem.

2) The user's use of the business is also a consistent hash to consider one of the inputs. For a business registered on Akamai, one or more uniformly assigned serial numbers are obtained, and Akamai can store the objects according to serial numbers and request hash to cluster the same machine (or collection) for different files of the same serial number. The need to download as many objects as possible for some client-side multiplexing connections (such as storing small objects on the same Web interface on a single machine as much as possible).

Leader election and data consistency

Even if the running programs on the two machines are identical, since the runtime's separate collection of input data may result in a different output, this situation requires leader election to select a leader in the server group to distribute the results of the operation to the other servers to unify the output. The problem of data consistency is encountered in leader selection process, which can be solved by Paxos or raft algorithm. I found the following two addresses, I feel the two algorithm is relatively easy to understand:

Paxos:paxos and distributed Systems

Raft:understandable Distributed Consensus

There are two types of leader election:

1) At-least-one Leader election: Select at least one Leader.

2) At-most-one Leader election: At most one Leader is selected.

For example, when a network problem causes a cluster to appear two subnets, if the algorithm using At-most-one Leader election class will not allow the selection of two Leader, but rather to abandon the Leader election process, using older decision data. For example, the process of Akamai User Group division, if there are two user Group division results in the network, will cause the global load balancing operation problems, so in this case can not elect two leader, rather use the old bit of user group to divide the results.

Akamai's algorithmic research in content distribution networks (translation summary)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.