A book I am reading makes the following statement:
Tasks will allow us to do one-off jobs and still rely on the rich OTP library. Connection pooling libraries let us share long-running connections across processes.
So, my understanding of this is as follows:
- if I have a one off task, I should use tasks
- if I need persistent connections to something, I should use pools
Why not always use pools?
And this is my questions. Even if I have one-off tasks, I still think pools are superior because they don’t have to create a new process to do the work, everything is already created.
I could understand the argument here if using pools was significantly harder than using one-off Tasks, but today with libraries like poolboy and books like Elixir in Action I do feel it is easy to understand, create and use pools these days.
- What are the major benefits of using one-off Tasks instead of a Pool?
- In what scenario would I be better of using a one-off Task instead of a Pool?