I'd be curious how ETS does on that problem. The Erlang efficiency guide says an ETS table takes:
> Initially 768 words + the size of each element (6 words + the size of Erlang data). The table grows when necessary.
This might be too large if there's a ton of them, but perhaps a single table per node could be workable? In particular, ordered_set tables with write_concurrency have been improved a lot on Erlang/OTP-22:
OTP-15128 Application(s): erts, stdlib
ETS option write_concurrency now also affects and
improves the scalability of ordered_set tables. The
implementation is based on a data structure called
contention adapting search tree, where the lock
granularity adapts to the actual amount of concurrency
exploited by the applications in runtime.