How can I calculate optimal batch sizes for calls to an external server?
Here's the simplest model I can think of.  Assume that each command takes $\beta$ seconds to complete, and it takes $\alpha$ seconds to create a connection.  Then I would expect that it would take $\alpha+\beta k$ seconds to complete a batch of size $k$.  If there are $N$ commands in total, then we'll need $N/k$ batches.  With 6 concurrent TCP connections to the server at a time, this means it'll take $N/(6k) \times (\alpha + \beta k)$ seconds to complete all of the batches.  As a function of the batch size, this is

$$f(k) = {\alpha + \beta k \over 6k} N.$$

You can find the optimal batch size by finding $k$ that minimizes $f(k)$, which can in turn be done using calculus by taking the derivative and setting it to zero: $f'(k)=0$.  Note that

$$f'(k) = {6\beta k - 6(\alpha + \beta k) \over 36k^2} N
= {\alpha \over 6k^2} N.$$

Setting this to zero, we find that $f(k)$ is minimized by taking $k$ as large as possible; in the limit we have $\lim_{k \to \infty} f(k) = \beta/6 N$.

Obviously, this is not what you observe empirically, which suggests that this model is not accurate.  I suggest as a next step you start to brainstorm why the model might be inaccurate or what factors it might be overlooking.  You might also want to measure and plot some additional metrics, e.g., the average time it takes for each batch to complete (as a function of batch size, i.e., the time between starting execution of command 0 from batch $i$ to starting execution of command 0 from batch $i+1$).