1. A computer implemented method for latency assignment in a system having shared resources for performing jobs, comprising: computing a new resource price at each resource based on latencies in a previous iteration; sending the new resource price to a task controller that has at least one subtask running at the resource, wherein each subtask has an initial deadline; determining new deadlines for the subtasks in a task based on the new resource prices at the task controller, comprising determining an optimal deadline by maximizing an objective function based on utility functions for each task, wherein the utility functions are based on a percentile of a task latency; and sending the new deadlines to the resources where at least one subtask in the task is running to improve system performance.