Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Batch - how to choose machine type?

Hi,

I'm a little confused about how select InstancePolicy.machine_type when creating jobs through Batch.

Let's say that I have a task which needs 2000 milliCpu and 2000 MiB and I want to run 200 of them. What should I choose for a machine type? If I want complete parallelism (e.g. 200) does that change anything?

Some particular cases I don't understand from the API documentation:

  • If I choose n1-standard-1 with only one vCPU will it fail to run any tasks?
  • If I choose n1-standard-4 will it run 2 tasks per VM? Will it be wasting 15 - 2*2 = 11 GB of ram?
  • Can I leave machine_type unspecified and have it automatically determined for efficiency?

Thank you!

0 4 913
4 REPLIES 4

Batch has a goal to choose machine type intelligently if users don't specify one, but there is a lot room for improvement today. In the particular examples, I think the current behaviors are

. If I choose n1-standard-1 with only one vCPU will it fail to run any tasks?

>> Batch will try to schedule 1 task per VM trusting that is the intention of the user.

. If I choose n1-standard-4 will it run 2 tasks per VM? Will it be wasting 15 - 2*2 = 11 GB of ram?

>> Yes. Batch uses CPU numbers to infer one VM can run at most 2 tasks.

. Can I leave machine_type unspecified and have it automatically determined for efficiency?

>> Yes. Today Batch will select an e2 machine although the behavior could change.

Thank you. I will experiment with leaving the machine type unspecified.

Hi,

That worked well for me, thank you! Just a brief follow up question:

What if I don't specify CPU requirements in compute resources or machine type in an instance policy? Can Batch autoscale my job so that each task is automatically provisioned with sufficient CPU?

Thanks

In that case, Batch will apply a pretty low default CPU requirements to tasks (which may not be sufficient) and use that to come up with a machine type.