1. A method for determining and executing optimal virtual machine assignments for reducer tasks on physical hosts, the method comprising: determining a distribution of keys over mapper virtual machines after map tasks are complete, wherein the distribution of keys comprises, for each key and for each mapper virtual machine, a number of key-value pairs for the particular key stored with the particular mapper virtual machine; determining costs associated with assignments of virtual machines to reducer tasks on the keys based on the distribution of keys; defining a variable matrix for assigning virtual machines to reducer tasks, wherein the variable matrix comprises values indicating whether a virtual machine is to be assigned to reduce one or more keys, and the variable matrix has dimensions of at least n by (M+p*q), where n is the number of keys, M is the number of mapper virtual machines, p is n−M, and q is the number of available physical hosts on which a virtual machine can be created; determining the optimal virtual machine assignments for the reducer tasks, using a constraints solver, based on the variable matrix and the costs, subject to one or more constraints on the variable matrix; and assigning, according to the optimal virtual machine assignments, the reducer tasks for execution by the virtual machines on the physical hosts.