Boosting Redis Performance: Deep Dive into Lettuce and Redisson Pipeline Support in Spring Boot
This article analyzes how Redis pipelining works, compares Lettuce and Redisson clients under Spring Boot, presents performance benchmarks for batch inserts, discusses practical pitfalls, and explains the internal implementation of pipeline support in both clients to help developers avoid common issues.
Introduction
Redis uses a client‑server TCP model with request/response semantics. When many commands need to be executed in batch, Redis offers the Pipeline feature to reduce round‑trip time (RTT) and improve throughput. This article examines how the Lettuce and Redisson clients in a Spring Boot environment support pipeline, provides performance measurements, and shares lessons learned from real‑world usage.
Pipeline Fundamentals
In a normal request, the client sends a command, blocks waiting for the server’s response, and then processes the result. The three‑step flow is:
Client issues a request and blocks on the socket.
Server processes the command and returns a result.
Client receives the result and resumes execution.
Pipeline reduces the number of network round‑trips by sending multiple commands in one write operation and receiving all replies in a single read, thus cutting down both RTT and the number of costly user‑to‑kernel context switches.
Basic Usage and Performance Comparison
We benchmarked inserting 100,000 SET entries using three approaches:
@Slf4j
public class RedisPipelineTestDemo {
public static void main(String[] args) {
// Jedis single inserts
Jedis jedis = new Jedis("10.101.17.180", 6379);
String zSetKey = "Pipeline-test-set";
int size = 100000;
long begin = System.currentTimeMillis();
for (int i = 0; i < size; i++) {
jedis.sadd(zSetKey + i, "aaa");
}
log.info("Jedis single insert time: {}ms", System.currentTimeMillis() - begin);
// Jedis pipeline
Pipeline pipeline = jedis.pipelined();
begin = System.currentTimeMillis();
for (int i = 0; i < size; i++) {
pipeline.sadd(zSetKey + i, "bbb");
}
pipeline.sync();
log.info("Jedis pipeline time: {}ms", System.currentTimeMillis() - begin);
// Redisson pipeline (RBatch)
Config config = new Config();
config.useSingleServer().setAddress("redis://10.101.17.180:6379");
RedissonClient redisson = Redisson.create(config);
RBatch batch = redisson.createBatch();
begin = System.currentTimeMillis();
for (int i = 0; i < size; i++) {
batch.getSet(zSetKey + i).addAsync("ccc");
}
batch.execute();
log.info("Redisson pipeline time: {}ms", System.currentTimeMillis() - begin);
// Cleanup
pipeline.close();
jedis.close();
redisson.shutdown();
}
}Results:
Jedis single insert: 162,655 ms
Jedis pipeline: 504 ms
Redisson pipeline: 1,399 ms
Pipeline dramatically outperforms individual commands, with Jedis pipeline being the fastest in this test.
Real‑World Application
In a production scenario, we needed to update icon styles for millions of users during holidays. The workflow stores per‑user icon identifiers in Redis, and we batch‑write these values using pipeline to avoid excessive latency.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
