Sleep is critical for diverse aspects of brain function in animals ranging from invertebrates to humans. Powerful genetic tools in the fruit fly Drosophila melanogaster have identified - at an unprecedented level of detail - genes and neural circuits that regulate sleep. This research has revealed that the functions and neural principles of sleep regulation are largely conserved from flies to mammals. Further, genetic approaches to studying sleep have uncovered mechanisms underlying the integration of sleep and many different biological processes, including circadian timekeeping, metabolism, social interactions, and aging. These findings show that in flies, as in mammals, sleep is not a single state, but instead consists of multiple physiological and behavioral states that change in response to the environment, and is shaped by life history. Here, we review advances in the study of sleep in Drosophila, discuss their implications for understanding the fundamental functions of sleep that are likely to be conserved among animal species, and identify important unanswered questions in the field.