Zettuce

Spring Boot, Micronaut & Quarkus

First-class integrations for Spring Boot / Spring Data Redis (zettuce-spring), Micronaut Cache & Template (zettuce-micronaut), Micrometer & OpenTelemetry (zettuce-observability), and Quarkus—all built on zero-dependency zettuce-java (Java 22+ FFM).

Production performance checklist

Unlike Lettuce (which multiplexes onto Netty event loops), each ValkeyRdmaConnection is a dedicated, single-owner native handle backed by an RDMA Queue Pair + pinned Memory Region (or a Linux io_uring ring). Follow five rules for peak throughput and minimal p99 tail latency:

Required JVM flag (least-privilege JPMS vs. fat JAR): zettuce-java ships an explicit module-info.java (ai.intellistream.zettuce). For least privilege, keep zettuce-java-0.9.3.jar on --module-path (-p) and pass --add-modules ai.intellistream.zettuce --enable-native-access=ai.intellistream.zettuce so only Zettuce gets native FFM access (no other JAR on -cp). For single fat/shadow JARs, use --enable-native-access=ALL-UNNAMED. On RDMA hosts, also set LimitMEMLOCK=infinity (ulimit -l unlimited).

Sync pool vs. async CompletableFuture overhead

Measured on AlmaLinux 10.3 / OpenJDK 25 (50,000 GET 64B ops) over both 56G InfiniBand RDMA and native io_uring TCP so you can see what each threading layer costs:

Execution pattern56G InfiniBand RDMANative io_uring TCPWhen to use
Direct conn.get() (sync)2.76 µs p50 / 3.91 µs p9934.11 µs p50Dedicated single-threaded worker / benchmark
pool.execute(...) (sync, caller thread)2.84 µs p50 / 3.88 µs p9932.73 µs p50Default & fastest — Spring MVC, Micronaut @ExecuteOn(BLOCKING), Quarkus @Blocking
pool.async() (bounded platform pool)11.82 µs p50 / 64.38 µs p99116.0 µs p50 (c=1 cold wake)Async event-loop callers (Netty filters, Spring WebFlux, reactive Quarkus) — avoids pinning virtual-thread carriers
16-thread sync pool.execute(...)925,876 ops/s195,662 ops/sMaximum sustained throughput with zero per-op future handoff

Spring Boot (3.x / 4.x) — zettuce-spring

Add zettuce-spring to get full Spring Data Redis (RedisConnectionFactory, RedisTemplate, StringRedisTemplate, pipelines, MULTI/EXEC, Lua scripting with NOSCRIPT → EVAL fallback, typed SCAN) plus Spring Cache (@Cacheable / @CachePut / @CacheEvict via RedisCacheManager) and Actuator ZettuceHealthIndicator via zero-config Spring Boot AutoConfiguration. Your existing beans automatically take precedence via @ConditionalOnMissingBean, and any registered CommandListener beans (such as Micrometer or OpenTelemetry from zettuce-observability) are auto-wired.

<dependency>
  <groupId>ai.intellistream.zettuce</groupId>
  <artifactId>zettuce-spring</artifactId>
  <version>0.9.3</version>
</dependency>
<!-- Optional: Micrometer metrics + OpenTelemetry tracing -->
<dependency>
  <groupId>ai.intellistream.zettuce</groupId>
  <artifactId>zettuce-observability</artifactId>
  <version>0.9.3</version>
</dependency>
# src/main/resources/application.yml
# Keep standard platform servlet worker threads (do NOT enable virtual threads for
# blocking native FFM I/O, which can pin virtual-thread carriers under slow replies).
zettuce:
  host: 10.99.99.41
  port: 6379
  tcp-fallback-port: 6380
  transport: AUTO     # RDMA | TCP | UNIX | AUTO
  username: app-user
  password: ${VALKEY_PASSWORD:}
  database: 0
  resp-version: 3
  client-name: ${spring.application.name:orders-svc}
  pool-max-size: 32   # ~2x vCPU
  connect-timeout: 3s
  io-timeout: 2s
  cache-ttl: 15m      # Default TTL for @Cacheable entries
  tls:
    enabled: false    # Set true for TLS 1.2/1.3 or mTLS over TCP
    ca-cert-file: /etc/certs/ca.crt
    verify-mode: FULL # FULL | CA_ONLY | NONE
    min-version: TLS_1_2
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import ai.intellistream.zettuce.ValkeyRdmaPool;

import java.time.Duration;
import java.util.List;

@Service
public class OrderCacheService {
    private final StringRedisTemplate redis;
    private final ValkeyRdmaPool pool; // Also auto-configured for direct zero-copy batching

    public OrderCacheService(StringRedisTemplate redis, ValkeyRdmaPool pool) {
        this.redis = redis;
        this.pool = pool;
    }

    @Cacheable(cacheNames = "orders", key = "#orderId")
    public String loadOrder(String orderId) {
        return fetchFromDatabase(orderId);
    }

    @CachePut(cacheNames = "orders", key = "#orderId")
    public String saveOrder(String orderId, String payload) {
        return payload;
    }

    @CacheEvict(cacheNames = "orders", key = "#orderId")
    public void evictOrder(String orderId) {}

    public void setStatus(String orderId, String status) {
        redis.opsForValue().set("order:status:" + orderId, status, Duration.ofMinutes(15));
    }

    /** Ultra-low-latency path: bypass Spring serialization and send 1 RDMA doorbell / 1 io_uring syscall. */
    public List<Object> loadOrderSnapshot(String orderId, String userId) {
        return pool.execute(c -> {
            var batch = c.batch();
            batch.get("order:status:" + orderId);
            batch.get("user:" + userId);
            return batch.execute();
        });
    }
}

To disable Zettuce's auto-configured CacheManager while keeping RedisTemplate, set spring.cache.type=none or supply your own CacheManager bean. For zero-latency startup on RDMA hosts, add an ApplicationRunner that borrows and pings pool connections during boot.

Micronaut (4.x / 5.x) — zettuce-micronaut

Add zettuce-micronaut for first-class Micronaut @Cacheable / @CachePut / @CacheInvalidate (backed by ZettuceCacheManager, SyncCache, and AsyncCache), a generic ZettuceTemplate<K, V> with pluggable ZettuceCodec, and a Micronaut Management ZettuceHealthIndicator. Offload blocking calls off Netty's event loop with @ExecuteOn(TaskExecutors.BLOCKING) backed by a fixed platform-thread pool.

<dependency>
  <groupId>ai.intellistream.zettuce</groupId>
  <artifactId>zettuce-micronaut</artifactId>
  <version>0.9.3</version>
</dependency>
# src/main/resources/application.yml
zettuce:
  enabled: true       # Set false to opt out cleanly without breaking @Cacheable beans
  host: 10.99.99.41
  port: 6379
  tcp-fallback-port: 6380
  transport: AUTO
  password: ${VALKEY_PASSWORD:}
  resp-version: 3
  client-name: ${micronaut.application.name:orders-mn}
  pool-max-size: 32
  cache-key-prefix: "zettuce:cache"
  cache-ttl: 15m
  # Default conservative JEP 290 ObjectInputFilter allows primitives/wrappers/String/UUID/java.time/enums
  # and rejects everything else (!*). Add your own Serializable DTO packages as needed:
  cache-deserialization-filter: "com.example.dto.**;java.lang.*;java.util.UUID;java.time.*;!*"
  tls:
    enabled: false

micronaut:
  caches:
    catalog:
      expire-after-write: 5m   # Per-cache TTL override honored by ZettuceCacheManager
  executors:
    blocking:
      type: fixed     # Bounded platform worker threads (avoids pinning virtual-thread carriers on native FFM I/O)
      nThreads: 32
import ai.intellistream.zettuce.ValkeyRdmaPool;
import ai.intellistream.zettuce.ZettuceCodec;
import ai.intellistream.zettuce.micronaut.ZettuceTemplate;
import io.micronaut.cache.annotation.CacheInvalidate;
import io.micronaut.cache.annotation.CachePut;
import io.micronaut.cache.annotation.Cacheable;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.scheduling.TaskExecutors;
import io.micronaut.scheduling.annotation.ExecuteOn;
import jakarta.inject.Singleton;

import java.time.Duration;

@Singleton
public class CatalogService {
    @Cacheable("catalog")
    public String lookupItem(String id) {
        return fetchItemFromDb(id);
    }

    @CachePut(value = "catalog", parameters = "id")
    public String replaceItem(String id, String value) {
        return value;
    }

    @CacheInvalidate("catalog")
    public void evictItem(String id) {}
}

@Controller("/orders")
public class OrderController {
    private final ZettuceTemplate<String, String> template;
    private final CatalogService catalog;

    public OrderController(ZettuceTemplate<String, String> template, CatalogService catalog) {
        this.template = template;
        this.catalog = catalog;
    }

    @Get("/{id}")
    @ExecuteOn(TaskExecutors.BLOCKING)   // Fastest path: platform blocking executor (~2.8 us RDMA p50)
    public String getOrder(String id) {
        template.set("order:last-read", id, Duration.ofMinutes(5));
        return catalog.lookupItem(id);
    }
}

Need custom binary/JSON serialization? Call template.withCodec(myCodec) for a zero-overhead typed view backed by the same ValkeyRdmaPool. Multiple CommandListener beans registered in Micronaut's context are automatically composed into a single listener chain.

Micrometer & OpenTelemetry — zettuce-observability

zettuce-observability plugs directly into Zettuce's zero-overhead CommandListener SPI (both in standalone Java apps and automatically when declared as beans in Spring Boot or Micronaut):

import ai.intellistream.zettuce.*;
import ai.intellistream.zettuce.observability.*;
import io.micrometer.core.instrument.MeterRegistry;
import io.opentelemetry.api.OpenTelemetry;

// 1. Micrometer: command latency timers, error counters, pool gauges & client-cache hit/miss/invalidation gauges
ZettuceMicrometerBinder micrometer = new ZettuceMicrometerBinder();

// 2. OpenTelemetry: CLIENT spans with db.system=valkey, db.operation.name, server.address, server.port
ZettuceOpenTelemetryListener otel = new ZettuceOpenTelemetryListener(openTelemetry);

// 3. Compose both listeners on your connection/pool options (keys/values are never added to span attributes)
RdmaConnectionOptions opts = RdmaConnectionOptions.builder()
        .transport(RdmaConnectionOptions.Transport.AUTO)
        .tcpFallbackPort(6380)
        .commandListener(new CompositeCommandListener(micrometer, otel))
        .build();

ValkeyRdmaPool pool = Zettuce.boundedPool(
        "198.51.100.11", 6379, 32, 32, Duration.ofSeconds(2), Duration.ofMinutes(5), opts);
micrometer.bindPool("orders", pool);
micrometer.bindTo(meterRegistry);

Quarkus (3.x)

Use SmallRye @ConfigMapping, an @ApplicationScoped CDI producer with @Disposes for deterministic QP/MR cleanup, @Startup pre-warming, SmallRye @Readiness health checks, and @Blocking on REST endpoints so Quarkus executes synchronous FFM I/O on platform worker threads without blocking Vert.x event loops or pinning virtual-thread carriers.

# src/main/resources/application.properties
zettuce.host=10.99.99.41
zettuce.port=6379
zettuce.tcp-fallback-port=6380
zettuce.transport=AUTO
zettuce.password=${VALKEY_PASSWORD:}
zettuce.resp-version=3
zettuce.client-name=orders-quarkus
zettuce.busy-poll=false
zettuce.spin-micros=50
zettuce.pool.max-total=32
zettuce.pool.max-idle=32
zettuce.pool.pre-warm=16
zettuce.pool.borrow-timeout=PT2S
zettuce.pool.idle-timeout=PT5M
package com.example.cache;

import io.quarkus.runtime.StartupEvent;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import ai.intellistream.zettuce.*;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Disposes;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Readiness;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Optional;

@ConfigMapping(prefix = "zettuce")
public interface ZettuceConfig {
    @WithDefault("127.0.0.1") String host();
    @WithDefault("6379") int port();
    @WithDefault("6380") int tcpFallbackPort();
    @WithDefault("AUTO") RdmaConnectionOptions.Transport transport();
    Optional<String> password();
    @WithDefault("3") int respVersion();
    @WithDefault("quarkus-svc") String clientName();
    @WithDefault("false") boolean busyPoll();
    @WithDefault("50") int spinMicros();
    Pool pool();

    interface Pool {
        @WithDefault("32") int maxTotal();
        @WithDefault("32") int maxIdle();
        @WithDefault("16") int preWarm();
        @WithDefault("PT2S") Duration borrowTimeout();
        @WithDefault("PT5M") Duration idleTimeout();
    }
}

@ApplicationScoped
public class ZettuceProducer {

    @Inject
    ZettuceConfig cfg;

    @Produces
    @Singleton
    public ValkeyRdmaPool createPool() {
        RdmaConnectionOptions.Builder b = RdmaConnectionOptions.builder()
                .transport(cfg.transport())
                .tcpFallbackPort(cfg.tcpFallbackPort())
                .respVersion(cfg.respVersion())
                .clientName(cfg.clientName())
                .busyPoll(cfg.busyPoll())
                .spinMicros(cfg.spinMicros())
                .connectTimeout(Duration.ofSeconds(3))
                .ioTimeout(Duration.ofSeconds(2))
                .retryPolicy(RdmaConnectionOptions.RetryPolicy.SAFE_ONLY);
        cfg.password().filter(s -> !s.isEmpty()).ifPresent(b::auth);

        RdmaConnectionOptions opts = b.build();
        ValkeyRdmaClient client = opts.getTransport() == RdmaConnectionOptions.Transport.UNIX
                ? ValkeyRdmaClient.createUnix(cfg.host(), opts)
                : ValkeyRdmaClient.create(cfg.host(), cfg.port(), opts);

        return new ValkeyRdmaPool(
                client,
                cfg.pool().maxTotal(),
                cfg.pool().maxIdle(),
                cfg.pool().borrowTimeout(),
                cfg.pool().idleTimeout());
    }

    void closePool(@Disposes ValkeyRdmaPool pool) {
        pool.close();
    }

    void onStart(@Observes StartupEvent ev, ValkeyRdmaPool pool) {
        int n = Math.min(cfg.pool().preWarm(), cfg.pool().maxTotal());
        var held = new ArrayList<ValkeyRdmaConnection>(n);
        try {
            for (int i = 0; i < n; i++) {
                ValkeyRdmaConnection c = pool.borrow();
                c.ping();
                held.add(c);
            }
        } finally {
            held.forEach(pool::release);
        }
    }
}

@Readiness
@ApplicationScoped
public class ZettuceReadinessCheck implements HealthCheck {
    @Inject
    ValkeyRdmaPool pool;

    @Override
    public HealthCheckResponse call() {
        try {
            var m = pool.execute(c -> {
                c.ping();
                return c.metrics();
            });
            return HealthCheckResponse.named("zettuce")
                    .up()
                    .withData("transport", m.activeTransport().name())
                    .withData("reconnects", m.reconnects())
                    .build();
        } catch (Exception e) {
            return HealthCheckResponse.named("zettuce").down().withData("error", e.getMessage()).build();
        }
    }
}

@Path("/orders")
public class OrderResource {
    @Inject
    ValkeyRdmaPool pool;

    @GET
    @Path("/{id}")
    @Blocking             // Runs on Quarkus platform worker pool (never blocks Vert.x event loop or pins virtual threads)
    public String getOrder(@PathParam("id") String id) {
        return pool.execute(c -> c.get("order:" + id));
    }
}

GraalVM Native Image support: zettuce-java ships built-in META-INF/native-image/.../reachability-metadata.json and native-image.properties for GraalVM 25+ (registering all Panama FFM downcalls/upcalls, shared arenas, and bundled libvalkey_rdma_ffm.so resources, verified in CI). Build native images with -H:+UnlockExperimentalVMOptions -H:+ForeignAPISupport -H:+SharedArenaSupport --enable-native-access=ALL-UNNAMED, or run in JVM mode on JDK 22+/25. Native-image metadata for zettuce-spring and zettuce-micronaut is included as experimental; register any custom serialized cache value classes in your application's serialization metadata.

Cluster bean & production JVM flags

For Valkey/Redis Cluster deployments, register a singleton ValkeyRdmaClusterClient (which is already thread-safe internally and handles MOVED/ASK/TRYAGAIN slot routing) with destroyMethod = "close" / @Disposes:

// Works identically as a @Bean (Spring), @Singleton @Bean(preDestroy="close") (Micronaut), or @Produces @Singleton (Quarkus)
RdmaConnectionOptions opts = RdmaConnectionOptions.builder()
        .transport(RdmaConnectionOptions.Transport.AUTO)
        .rdmaPortOffset(100)       // e.g. cluster announces TCP 7001, RDMA listens on 7101
        .respVersion(3)
        .spinMicros(50)
        .build();

ValkeyRdmaClusterClient cluster = ValkeyRdmaClusterClient.connect("10.99.99.41", 7001, opts);

Recommended production JVM flags for Spring Boot, Micronaut, and Quarkus on Linux (JDK 25). Placing zettuce-java-0.9.3.jar on -p restricts Panama FFM native access exclusively to ai.intellistream.zettuce:

# Least-privilege JPMS launch (recommended: only ai.intellistream.zettuce gets native FFM access)
java \
  -p /opt/orders/mods/zettuce-java-0.9.3.jar \
  --add-modules ai.intellistream.zettuce \
  --enable-native-access=ai.intellistream.zettuce \
  -XX:+UseZGC \
  -XX:+AlwaysPreTouch \
  -Xms4g -Xmx4g \
  -cp '/opt/orders/lib/*' \
  com.example.orders.Application

# Alternative for single fat/shadow JARs (all classes live in ALL-UNNAMED)
java \
  --enable-native-access=ALL-UNNAMED \
  -XX:+UseZGC \
  -XX:+AlwaysPreTouch \
  -Xms4g -Xmx4g \
  -jar /opt/orders/orders-all.jar

systemd service & NIC-local NUMA pinning

On dual-socket or multi-NUMA servers, every PCIe network card (InfiniBand/RoCE HCA or 25/100 GbE NIC) is physically wired to a single CPU socket's PCIe root complex. If your JVM threads or RDMA Memory Regions live on the other NUMA node, every DMA transfer and completion poll crosses the inter-socket UPI/xGMI interconnect—adding 1–3 µs of latency and reducing throughput. Pinning your Java service's CPUs and memory strictly to the NIC's NUMA node eliminates cross-socket hops completely.

1. Identify the NUMA node attached to your NIC

# For an RDMA HCA (e.g. mlx5_0 or mlx4_0):
cat /sys/class/infiniband/mlx5_0/device/numa_node       # e.g. 1
cat /sys/class/infiniband/mlx5_0/device/local_cpulist   # e.g. 16-31,48-63

# Or by Linux network interface name (e.g. ens3f0, enp94s0, ib0):
cat /sys/class/net/ens3f0/device/numa_node              # e.g. 1
cat /sys/class/net/ens3f0/device/local_cpulist          # e.g. 16-31,48-63

# Inspect full NUMA topology (CPUs + RAM per node):
numactl --hardware

2. Production systemd unit pinned to the NIC's NUMA node

Suppose your RDMA / 100 GbE NIC is attached to NUMA node 1 with local CPUs 16-31. Save the following unit as /etc/systemd/system/orders-svc.service (works identically for Spring Boot, Micronaut 5, and Quarkus JVM distributions):

[Unit]
Description=Orders Service (Zettuce Java 25 FFM, NUMA-pinned to NIC node 1)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=orders
Group=orders
WorkingDirectory=/opt/orders

# Pin CPU scheduling and memory allocation strictly to the NIC's NUMA node (node 1)
NUMAPolicy=bind
NUMAMask=1
CPUAffinity=16-31
# On cgroups v2 (systemd 244+, RHEL 9/10, Ubuntu 24.04+, Debian 12/13, Fedora),
# AllowedCPUs/AllowedMemoryNodes enforce hard cpuset isolation for all child threads too:
AllowedCPUs=16-31
AllowedMemoryNodes=1

# Required for RDMA ibv_reg_mr() memory pinning & high-concurrency sockets
LimitMEMLOCK=infinity
LimitNOFILE=65536

EnvironmentFile=-/etc/orders-svc/env

# Least-privilege JPMS launch: only ai.intellistream.zettuce receives native FFM access.
# -XX:+AlwaysPreTouch faults the entire Java heap onto NUMA node 1 during startup.
ExecStart=/usr/lib/jvm/java-25/bin/java \
  -p /opt/orders/mods/zettuce-java-0.9.3.jar \
  --add-modules ai.intellistream.zettuce \
  --enable-native-access=ai.intellistream.zettuce \
  -XX:+UseZGC \
  -XX:+AlwaysPreTouch \
  -Xms4g -Xmx4g \
  -cp /opt/orders/lib/* \
  com.example.orders.Application

Restart=on-failure
RestartSec=3s
TimeoutStopSec=30s

# Service hardening (compatible with RDMA /dev/infiniband and io_uring)
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/log/orders

[Install]
WantedBy=multi-user.target

Older systemd or ad-hoc CLI alternative: If you are launching outside systemd or on an environment without cgroups v2 AllowedMemoryNodes, wrap the command with numactl --cpunodebind=1 --membind=1 /usr/lib/jvm/java-25/bin/java ... (replace 1 with the NIC's numa_node).

3. Enable and verify NUMA locality

sudo systemctl daemon-reload
sudo systemctl enable --now orders-svc

# Confirm CPU affinity and NUMA memory binding of the running JVM:
PID=$(systemctl show -p MainPID --value orders-svc)
taskset -pc "$PID"                # Should list only CPUs from local_cpulist (e.g. 16-31)
numastat -p "$PID"                # Should show ~100% of heap & native MR memory on Node 1
grep -E 'Cpus_allowed_list|Mems_allowed_list' "/proc/$PID/status"