Hello, i began to explore Elixir and Phoenix recently and have decided to do some projects with it.
I need to read a file with a lot of urls (currently 1mil for testing) and serve that as json to clients.
The controller looks like this:
defmodule FnApiWeb.FetchBlacklist do
use FnApiWeb, :controller
@blacklist %{"sites" => File.read!("top1m.bcp")
|> String.split("\n", trim: true)
|> Enum.map(fn x -> "*://*." <> x <> "/*" end)}
def index(conn, _params) do
json(conn, @blacklist)
end
end
On 500, 1000 or 10000 urls memory usage and performance is great.
When i do 1mil it takes more than 4GB of RAM to even start the phoenix server.
I believe i’m doing something wrong and the code must be placed elsewhere but i’d like some help on this.