Energy allocation is believed to drive trade-offs in life history evolution. We develop a physiological and genetic model of energy allocation that drives evolution of feeding rate in a well-studied model system. In a variety of stressful environments Drosophila larvae adapt by altering their rate of feeding. Drosophila larvae adapted to high levels of ammonia, urea, and the presence of parasitoids evolve lower feeding rates. Larvae adapted to crowded conditions evolve higher feeding rates. Feeding rates should affect gross food intake, metabolic rates, and efficiency of food utilization. We develop a model of larval net energy intake as a function of feeding rates. We show that when there are toxic compounds in the larval food that require energy for detoxification, larvae can maximize their energy intake by slowing their feeding rates. While the reduction in feeding rates may increase development time and decrease competitive ability, we show that genotypes with lower feeding rates can be favored by natural selection if they have a sufficiently elevated viability in the toxic environment. This work shows how a simple phenotype, larval feeding rates, may be of central importance in adaptation to a wide variety of stressful environments via its role in energy allocation.