Skip to content

Discussion: optimistic lock conflicts with Redis backend #189

@wzihao81-ctrl

Description

@wzihao81-ctrl

Description

Hi, thanks for go-ipam!

When running go-ipam as a gRPC microservice with multiple instances + Redis, we see frequent optimistic lock conflicts under concurrent IP allocations/releases (~30 QPS, multiple namespaces). This leads to retries and higher latency.

From the code/behavior it seems each operation:

Uses an optimistic lock on a namespace key in Redis
Reads namespace state → modifies in memory → writes back
This works well for read-heavy loads, but becomes a bottleneck with steady concurrent writes.

For a simplified use case (mainly prefix + IP allocation/release), could we support an alternative Redis backend that:

For each {namespace, prefix}, keeps all allocatable IPs in a Redis SET
Allocation: SPOP (or SRANDMEMBER + SREM)
Release: SADD
This would rely on Redis atomic SET operations instead of namespace-level optimistic locking, potentially reducing conflicts in write-heavy scenarios.

Questions:

Would such a “SET-based” mode/backend fit the project direction (even as an optional/experimental feature)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: control-planeAffects the metal-stack control-plane area.area: networkAffects the network area.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions