Tasks vs GenServer

A task is meant to be an alternative to using spawn , but be otp conform (see :proc_lib ), so it can be properly supervised/shut down.

There’s also some elixir-only goodness in there with the :$callers stuff which makes async unit testing with Ecto, Mox, Hound, Wallaby, etc. effective.

In short, “almost always use Task over spawn”.

1 Like