title: Apache Flink: Correctly make async webservice calls within MapReduce()
body: <p>I've a program with the following <code>mapPartition</code> function:</p>
  
  <pre><code>public void mapPartition(Iterable&lt;Tuple&gt; values, Collector&lt;Tuple2&lt;Integer, String&gt;&gt; out)
  </code></pre>
  
  <p>I collect batches of 100 from the inputted <code>values</code> &amp; send them to a web-service for conversion. The result I add back to the <code>out</code> collection. </p>
  
  <p>In order to speed up the process, I made the web-service calls <code>async</code> through the use of <code>Executors</code>. This created issues, either I get the <a href="https://flink.apache.org/faq.html#the-slot-allocated-for-my-task-manager-has-been-released-what-should-i-do" rel="nofollow noreferrer">taskManager released exception</a>, or <code>AskTimeoutException</code>. I increased memory &amp; timeouts, but it didn't help. There's quite a lot of input data. I believe this resulted in a lot of jobs being queued up with <code>ExecutorService</code> &amp; hence taking up lots of memory. </p>
  
  <p>What would be the best approach for this? </p>
  
  <p>I was also looking at the taskManager vs taskSlot configuration, but got a little confused on the differences between the two (I guess they're similar to process vs threads?). Wasn't sure at what point do I increase the taskManagers vs taskSlots? e.g. if I've got three machines with 4cpus per machine, so then should my <code>taskManager=3</code> while my <code>taskSlot=4</code>? </p>
  
  <p>I was also considering increasing the <code>mapPartition</code>'s parallelism alone to say <code>10</code> to get more threads hitting the web-service. Comments or suggestions?</p>