[erlang-questions] Alternatives to Erlang
Jesper Louis Andersen
jesper.louis.andersen@REDACTED
Wed Feb 13 17:58:03 CET 2013
On Feb 11, 2013, at 6:29 PM, Maruthavanan Subbarayan <maruthavanan_s@REDACTED> wrote:
> Hi,
>
> I am on the way to creating an application which would create atoms dynamically.
>
> These atoms are created because I have user registering into my system and each user has set of 10 mnesia tables to be created. Since atoms has a limitation I am afraid that if 100K users register into my system I may run of atoms for creating tables for more users.
>
> Creating an ETS table with name will give me table identifier with integer. Does a similar thing exists for mnesia too?
>
You will run out of ETS tables long before you run out of atoms with that solution. You should probably have 10 mnesia tables in all, and then use a key where the user is part. That is, instead of storing `Key` as your key, you store `{User, Key}`. This means you would need 10 tables in all. And the performance would probably be better than keeping a large number of small tables.
As for the atom limit, let users be stored as (small) binaries or integers. Then you avoid that problem entirely. If you need to register a process under a user id, then use the `gproc` application by Ulf Wiger to maintain the lookup table for you. Look at the {via, …} registration in gen_server's for some hint.
Jesper Louis Andersen
Erlang Solutions Ltd., Copenhagen
More information about the erlang-questions
mailing list