 
   def run do
     Podcasts.list_podcasts
-    |> Enum.map(&(Task.async(fn -> do_fetch(&1) end)))
+    |> Enum.chunk(@batch_size)
+    |> Enum.each(&run_batch/1)
+  end
+
+  def run_batch(podcasts) do
+    podcasts
+    |> Enum.map(&Task.async(__MODULE__, :do_fetch, [&1]))
     |> Enum.map(&Task.await(&1, @await_timeout))
   end
 

  defp poolboy_config do
    [{:name, {:local, :worker}},
      {:worker_module, Worker},
      {:size, 20},
      {:max_overflow, 0}]
  end


  alias Podcatcher.Podcasts
  alias Podcatcher.Updater.Worker

  @batch_size 10
  @worker_timeout 1_000_000
  @await_timeout  1_000_000

