ets vs list

Max Lapshin <>
Mon Sep 13 14:58:25 CEST 2010

erlyvideo has video streams inside, each video stream is an object,
that tracks list of subscribed clients.
Each client can be in several states.

On each incoming frame clients are checked in this list and frame is
delivered to each. Also, clients may change their state and it happens
more rare, than selecting them from list.

Proportions are so: from 1000 clients, about 850 are usually in state
"active", 120 in "starting", 30 are "paused"
"active" clients receive each frame.

I was using ets to store their pids, but today I've created benchmark:

and it seems, that my choice was wrong:

15> c(bm_ets).
16> bm_ets:run().
Initialized, starting
[RO] ETS: 3987268, List: 422858
[RW] ETS: 4043659, List: 1213914

I can interpret these results so:
list is 10 times faster than ets on often full table scans and is 4
times faster, than 50/50:scan and update

My questions are:
1) are my conclusions right?
2) what ets is for, if list is fast enough on inserts? ets happened to
be unusable in creating timeshift (storing large binaries) because of
copy, it is much slower on extracting large amount of small objects.
Where should I use it?

More information about the erlang-questions mailing list