Golang distributed and---group hotspot elimination algorithm

Source: Internet
Author: User

Golang distributed and---group hotspot elimination algorithm

In the traditional algorithm, to calculate the hot spot, the general use, collect all the task list, and then sorted, get the top n hot data. The bad parts of this algorithm are:

1, need to collect all the task list. Collection is a problem when there are too many tasks

2, the task list to sort. In this procedure, if there are too many lists, the sort time is too long.

In addition, if synchronization is required, there will be a pause in this algorithm.

Then we build a scene, an internet café has n position, everyone can go to the Internet café, but the provision, only 1 hours each time, if the time is up, you can continue to one hours, if you do not need to give up the position.

Now there are m individuals to internet cafes.

1, M < n, then m individuals can get access to the Internet location

2, when m>n, then there are n individuals can get to the Internet location, the rest of the people are waiting

There are two kinds of scheduling algorithms

1, each person, will regularly check their own time, is not to 1 hours, if it is, then determine whether they need to continue to use, the priority of a contract extension of 1 hours, if you do not need to give up the position. Those who wait are randomly captured in this position.

2, everyone, will regularly check their own time, is not to 1 hours, if it is, then give up the position. If you need to continue to use it, go to the wait queue, do not need to use, and then exit directly.

In this algorithm, the places that need attention are

1, each user is self-discipline. Judge yourself whether you need to continue to use, judge yourself whether the time expires, etc.

2, it is very important to judge whether the standard can continue to be used. For example, when personal contribution to a certain degree, can continue to use.

The simple usage is to arrange the contribution of n individual, and eliminate the tail some

After a period of time, hot spots are automatically formed.

The advantage of this algorithm is that each individual is able to compete for opportunities independently and fairly, and only those individuals who have a greater contribution ratio will be allowed to use the time. This algorithm does not need to be synchronized and improves the concurrency efficiency.

Hao Haohua

The Long Crescent Moon Road

QQ 29185807

November 27, 2014 11:14:01


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.