Maximum number of Agents?

​I’m developing a Basket Manager ( ), each basket is a process created by Basket.Manager under Cart.Supervisor. This is the actual behavior:

basket_id = Basket.Manager.create_basket_or_return_basket_id(Basket.Manager, user_id)
basket_pid = Basket.Manager.get_basket(Basket.Manager, basket_id)
Basket.add_product(basket_pid, product_id)
Basket.delete_product(basket_pid, product_id)

I came with this solution because I don’t want to keep the state of basket inside Basket.Manager.The problem is elixir/erlang came with a limited number of Agents which can be spawn.
I’ve found a solution in this topic ->!topic/elixir-lang-talk/No1Qq0huj_E
I try to export ELIXIR_ERL_OPTS

alexandrubagu@alexandrubagu:~$ export ELIXIR_ERL_OPTS="+P 5000000"
alexandrubagu@alexandrubagu:~$ iex
iex(1)> System.get_env("ELIXIR_ERL_OPTS")
"+P 5000000"
iex(2)> stream = 1..4_000_000 |> Stream.each(fn(_) -> Agent.start_link(fn -> [] end) end)
#Stream<[enum: 1..4000000, funs: [#Function<38.64528250/1 in Stream.each/2>]]>
** (SystemLimitError) a system limit has been reached

19:33:24.567 [error] Too many processes

Is any solution for this ?
Thanks a lot

The environment variable is ELIXIR_ERL_OPTIONS. :slight_smile:


It works. Thanks for your reply, @josevalim :slight_smile: