Skip to content

Networking Layer

Speed is nothing without a frictionless delivery mechanism. LoomCache handles inter-node communication and client-server traffic through a highly optimized TCP layer built on Java NIO2 and Virtual Threads.

Rather than communicating via HTTP or REST JSON, LoomCache utilizes a hyper-efficient, custom binary protocol with 108 distinct message types.

Wire Protocol Pipelining

Zero-copy serialization with batched pipelining over persistent TCP connections.

CLIENT
OP
BIN
OP
BIN
OP
BIN
SERVER
  1. Header Structure: Every packet has a fixed-length header declaring the payload size, operation code (OP-Code), and a strict format. This enables zero-parse-ahead framing.
  2. Kryo 5.6.2 Serialization: Map entries and keys are serialized via Kryo’s high-performance binary format with object pooling to minimize GC pressure.
  3. Pipelining: Multiple commands can be flushed rapidly on the same connection (batch size configurable, default 100), significantly reducing round-trip latency.

Counts from MessageType.java:

CategoryExamples
Data operationsMAP_PUT, MAP_GET, QUEUE_OFFER, SET_ADD, TOPIC_PUBLISH
Raft consensusRAFT_APPEND_ENTRIES, RAFT_VOTE_REQUEST, RAFT_PRE_VOTE_REQUEST, RAFT_INSTALL_SNAPSHOT, RAFT_TIMEOUT_NOW
Cluster managementCLUSTER_JOIN, CLUSTER_LEAVE, CLUSTER_PING, PARTITION_TABLE, PARTITION_MIGRATE_START
Consistency subsystemCP_ATOMIC_GET, CP_ATOMIC_CAS (lock / semaphore opcodes exist but are currently rejected server-side)
Client controlAUTH, NEAR_CACHE_SUBSCRIBE, BATCH_EXECUTE, SQL_QUERY_EXECUTE
WAN / executorWAN_*, EXECUTOR_* (server-side scaffolding)
ResponsesRESPONSE_OK, RESPONSE_ERROR, RESPONSE_REDIRECT, RESPONSE_SERVER_BUSY, RESPONSE_SEQUENCE_LOST

Networking logic is separated via specialized execution arenas:

  • TcpServer — Virtual thread per connection. Blocks freely on I/O; JVM unmounts carrier thread automatically.
  • CommandExecutorPool — Dedicated pool for state machine operations. Prevents slow clients from backing up consensus.
  • BackpressureController — Watermark-based flow control. When the command queue fills, new connections are back-pressured rather than dropped.

Each connection is tracked by a ConnectionContext holding the negotiated TLS identity, resolved permission set, and per-connection request counters. ConnectionHealthMonitor closes connections that exceed the per-IP limit with TOO_MANY_CONNECTIONS.

LoomCache implements watermark-based backpressure via the BackpressureController:

WatermarkBehavior
Below low markNormal processing
Between marksNew connections throttled
Above high markNew connections rejected with BackpressureException

This prevents a thundering herd of clients from overwhelming the command queue and starving Raft replication.

Production deployments demand zero-trust encryption. LoomCache natively supports Mutual TLS (mTLS) for cluster inner-node communication. Each node validates the identity of adjoining nodes before participating in Raft elections or accepting writes.

  • TLSv1.3 by default with TLSv1.2 fallback
  • PKCS12 keystores for identity and trust
  • Per-connection TLS handshake via SslContextFactory
  • Client connections support optional mTLS (requireClientAuth toggle)