To stay healthy, plants balance the energy they put into growing with the amount they use to defend against harmful bacteria.