Since the discovery of antimicrobial peptide responses 40 years ago, the fruit fly Drosophila melanogaster has proven to be a powerful model for the study of innate immunity. Early work focused on innate immune mechanisms of microbial recognition and subsequent nuclear factor-κB signal transduction. More recently, D. melanogaster has been used to understand how the immune response is regulated and coordinated at the level of the whole organism. For example, researchers have used this model in studies investigating interactions between the microbiota and the immune system at barrier epithelial surfaces that ensure proper nutritional and immune homeostasis both locally and systemically. In addition, studies in D. melanogaster have been pivotal in uncovering how the immune response is regulated by both endocrine and metabolic signalling systems, and how the immune response modifies these systems as part of a homeostatic circuit. In this Review, we briefly summarize microbial recognition and antiviral immunity in D. melanogaster, and we highlight recent studies that have explored the effects of organism-wide regulation of the immune response and, conversely, the effects of the immune response on organism physiology.