Golang distributed concurrency---group hotspot elimination algorithm

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Golang distributed concurrency---group hotspot elimination algorithm

In the traditional algorithm, in order to calculate the hot spot, the general use, collects all the task list, then sorts, obtains the first n hot spot data. The bad places of this algorithm are:

1, need to collect all the task list. Collection is a problem when the number of tasks is too large

2. Sort the list of tasks. In this procedure, if the list is too large, 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 locations, everyone can go to the Internet cafes, but the rules, each time can only make an appointment for 1 hours, if the time is up, you can renew for one hours, if not required to give up the location.

Now there are m people to internet cafes.

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

2, when M>n, there are n individuals can get to the Internet location, the remaining people, is 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, to determine whether they need to continue to use, the preferential renewal of 1 hours, if not required to give up the location. Wait for the person, then randomly get to 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 still need to continue to use it in the wait queue and do not need to use it, exit directly.

In this algorithm, it is important to note where there are

1, each user is self-disciplined. Judge yourself whether you need to continue to use, judge whether you have time to expire, etc.

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

The simple usage is to sort the contributions of n individuals and eliminate the tail

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

The advantage of this algorithm is that each individual has a fair and equal opportunity to compete, and only the person with the greater contribution will be able to use the time. This algorithm does not need to be synchronized, which improves the concurrency efficiency.

Hao Haohua

QQ 29185807

November 27, 2014 11:14:01

Related Article
Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.