Magnit Tech engineers developed a Rust-based DTLS proxy to manage connectivity for 300,000 devices. The system uses the LwM2M protocol over CoAP and DTLS, requiring horizontal scaling in Kubernetes while maintaining session persistence during client network transitions.

The proxy sits in front of three independent LwM2M services: bootstrapping, registration, and management. It uses the Connection ID (CID) from DTLS 1.2 to identify sessions and the PROXY protocol v2 (PPv2) to pass original client IP and port information to the backend JVM servers.

Initial attempts to use XDP and DSR for packet handling failed because local routing tables caused handshake packets to be routed to servers lacking the necessary session state. The team shifted to a user-space implementation to simplify network management and diagnostics within the cloud environment.

To ensure consistent routing across proxy replicas without a shared database, the team implemented Rendezvous hashing (HRW). This deterministic algorithm allows all proxy instances to independently select the same backend server for a given session based on client data and server weights.

The system avoids state migration between servers, adhering to a one-session-per-server model. Server weights are managed via signed policies, allowing for controlled scaling and maintenance of pods without disrupting active connections.