Giter Site home page Giter Site logo

Comments (8)

mp911de avatar mp911de commented on May 23, 2024

Pipelining is a mechanism to send commands without awaiting completion of the previous command. That's exactly the default configuration setting to have a balance between command processing and latency. Since a framework cannot make any assumptions on how long you will wait between sending commands you can configure LettuceConnectionFactory.pipeliningFlushPolicy to your needs.

from spring-data-redis.

Blusez avatar Blusez commented on May 23, 2024

Pipelining is a mechanism to send commands without awaiting completion of the previous command. That's exactly the default configuration setting to have a balance between command processing and latency. Since a framework cannot make any assumptions on how long you will wait between sending commands you can configure LettuceConnectionFactory.pipeliningFlushPolicy to your needs.

If the default config is to submit a command every time, then what is the difference with loop to direct the command?
In jedis and lettuce, the default implementation of pipeline is the last to submit.
Why does spring-data want to change this?

from spring-data-redis.

mp911de avatar mp911de commented on May 23, 2024

then what is the difference with loop to direct the command?

Care to elaborate? I do not understand the question.

In jedis and lettuce, the default implementation of pipeline is the last to submit.

That's not true. Lettuce's async API submits commands without awaiting previous command completion. Also, there's no pipelining API. Also, Jedis sends commands to the pipeline directly, however, Jedis uses a BufferedOutputStream that buffers a few commands (up to 8kb of data IIRC).

from spring-data-redis.

Blusez avatar Blusez commented on May 23, 2024

then what is the difference with loop to direct the command?

I mean if default policy is flushEachCommand ,it same as :

for (int i = 0; i < 100; i++) {
 RedisTemplate.opsForValue().get("key:"+i);
}

in lettuce:,it pipeline is write all commands to the transport layer:
image

In my code I wanted to be able to submit all commands together, less network io, but after using spring-data -lettuce, all requests were submitted one by one,it causing the machine's out-of-heap memory to continue to rise, which made me feel very confused.

I notice Lettuce pipelining behaviour is different than Jedis pipelining.

and I think using pipeline, the default is to want to submit commands in batches, not one by one.

from spring-data-redis.

mp911de avatar mp911de commented on May 23, 2024

flushCommands is in Lettuce only an optimization to use netty's buffering mechanism for additional command buffering. Using flushCommands can be dangerous especially in multi-threaded arrangements.

If you're want to optimize for performance then using Lettuce directly is a good alternative.

from spring-data-redis.

Blusez avatar Blusez commented on May 23, 2024

What I mean is that pipeline should be more focused on batch submission, like the jedis implementation whitch buffer all commands and flush them to the transport at once, then it doesn't bother users.

But now the default policy in spring-data-redis is flushEachCommand,it can cause a lot of trouble for upgrades, and upgrades and switch implementations should not be such a big difference.so I think the default policy should be flushOnClose.

By the way ,in a production environment, direct use of redis pipeline policy of spring-data-redis , under certain conditions(it could be the Internet.), will cause off-heap memory to continue to rise, what is the reason for this? spring-data-redis version is 2.7.1.

from spring-data-redis.

mp911de avatar mp911de commented on May 23, 2024

There's a difference between pipelining and batching. We do not want to force all users into a particular scheme that appears convenient in a specific application.

Your other question relates to Lettuce's buffering feature upon disconnect. Please refer to ClientOptions.disconnectedBehavior and requestQueueSize for configuration options.

from spring-data-redis.

Blusez avatar Blusez commented on May 23, 2024

But when we use pipeline, we want to be able to execute it in batches. I think this is more general. Each command is submitted as a special scenario.

Inotice that the client disconnected buffer queue is an unbounded queue, but why use off-heap memory here?

from spring-data-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.