Solving the congestion problem of Redis cluster Jedis drive under high concurrency

Source: Internet
Author: User
Tags redis cluster

After Redis Cluster was released, we used cluster in the project, and the driver was Jedis, but during the stress test it was found that a certain number of Redis accesses were very slow up to dozens of seconds and a few minutes, After analysis Jedis drive Jedisclusterinfocache in the lock caused by

Private map<string, jedispool> nodes = new hashmap<string, jedispool> ();
Private Map<integer, jedispool> slots = new Hashmap<integer, jedispool> ();

Public Jedispool getnode (String nodekey) {
R.lock ();
try {
Return Nodes.get (Nodekey);
} finally {
R.unlock ();
}
}

Public Jedispool getslotpool (int slot) {
R.lock ();
try {
return Slots.get (slot);
} finally {
R.unlock ();
}
}

Replace the map with Concurrenthashmap

Private map<string, jedispool> nodes = new concurrenthashmap<string, jedispool> ();
Private Map<integer, jedispool> slots = new Concurrenthashmap<integer, jedispool> ();

Remove lock

Public Jedispool getnode (String nodekey) {
Return Nodes.get (Nodekey);
}

Public Jedispool getslotpool (int slot) {
return Slots.get (slot);
}

After testing the comparison process is relatively smooth, there is no time for a visit to a very long situation.

This article is from "Tianya Time and Space" blog, please make sure to keep this source http://leshjmail.blog.51cto.com/629172/1784716

Solving the congestion problem of Redis cluster Jedis drive under high concurrency

Related Article

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.