Immune response from a resource allocation perspective