Redis Could not get a resource from the pool basic content

Source: Internet
Author: User
Tags redis server

Cause: When the client goes to the Redis server to get the connection (the code describes the leased object Borrowobject), there is no connection available in the pool, that is, all connections in the pool are occupied, and when the timeout is not received after the wait time, the exception is reported.

2, the solution: adjust the jedispoolconfig in the maxactive to suit their own system threshold.
For example:
<bean id= "Datajedispoolconfig" class= "Redis.clients.jedis.JedisPoolConfig" >
<property name= "maxactive" value= "/>"
<property name= "Maxidle" value= "/>"
<property name= "maxwait" value= "10000"/>
<property name= "Testonborrow" value= "true"/>
</bean>

How Redis configures the Jedispool parameter

Jedispool configuration parameters depend heavily on the actual application requirements, hardware and software capabilities, Jedispool configuration parameters are mostly assigned by jedispoolconfig corresponding items.

Maxactive: Controls how many Jedis instances can be allocated by a pool, obtained through Pool.getresource (), or if the assignment is 1, which means no limit, or if the pool has already allocated maxactive Jedis instances, Then the state of the pool becomes exhausted, in Jedispoolconfig
Maxidle: Controls the maximum number of Jedis instances in a pool that have a status of idle;
Whenexhaustedaction: Represents the action that the pool takes when the Jedis instance in the pool is allocated, and there are three types of when_exhausted_fail by default, indicating that there are no Jedis instances. Throw nosuchelementexception directly), When_exhausted_block (either to block or to maxwait when Jedisconnectionexception is thrown), when_exhausted _grow (it means creating a new Jedis instance, also saying that the maxactive of the setting is useless);
Maxwait: Indicates that when borrow a Jedis instance, the maximum wait time, if the waiting time is exceeded, the jedisconnectionexception is thrown directly;
Testonborrow: Whether alidate operations are performed in advance when a Jedis instance is borrow, and if true, the resulting Jedis instances are available;
Testonreturn: Whether the validate operation is performed in advance when the return is given to the pool;
Testwhileidle: If true, indicates that there is an idle object Evitor thread that scans the idle object, and if the validate fails, the object is dropped from the pool ; This item is only meaningful if the Timebetweenevictionrunsmillis is greater than 0;
Timebetweenevictionrunsmillis: Indicates the number of milliseconds to sleep between idle object Evitor two scans;
Numtestsperevictionrun: Indicates the maximum number of objects per scan of the idle object evitor;
Minevictableidletimemillis: Represents the minimum time at which an object stays in the idle state before it can be scanned and evicted by an idle object evitor ; This item is only meaningful if the Timebetweenevictionrunsmillis is greater than 0;
Softminevictableidletimemillis: On the basis of minevictableidletimemillis, at least minidle objects have been added to the pool. If the -1,evicted does not expel any objects according to the idle time. If minevictableidletimemillis>0, this setting is meaningless and only makes sense if the Timebetweenevictionrunsmillis is greater than 0;
When Lifo:borrowobject returns an object, it takes Default_lifo (last in first out, which is the most frequently used queue similar to cache) and, if False, indicates a FIFO queue;

Where Jedispoolconfig the default settings for some parameters are as follows:
Testwhileidle=true
minevictableidletimemills=60000
timebetweenevictionrunsmillis=30000
Numtestsperevictionrun=-1

Redis Could not get a resource from the pool basic content

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.