What Affects Sleep Quality, According to Science

Sleep is controlled by two main systems in your brain: a built-in clock that tells you when to sleep, and a pressure system that builds the longer you stay awake. Almost everything that affects your sleep, from your afternoon coffee to your bedroom temperature, works by interfering with one or both of these systems. Understanding what pulls the levers on your sleep can help you figure out why you’re not getting enough of it.

The Two Systems That Control Sleep

Your brain tracks how long you’ve been awake by accumulating a chemical called adenosine. The longer you’re up, the more adenosine builds in your brain, gradually quieting the regions that keep you alert. This is why you feel progressively sleepier as the day wears on. When you finally sleep, your brain clears adenosine, resetting the counter for the next day.

Running alongside this pressure system is your circadian rhythm, a roughly 24-hour internal clock housed in a small cluster of brain cells that responds to light. When light hits your eyes, signals reach this clock and suppress the production of melatonin, the hormone that primes your body for sleep. As evening darkness arrives, melatonin levels rise, your core body temperature drops, and your brain begins preparing for sleep. These two systems, sleep pressure and circadian timing, work together. Anything that disrupts either one can leave you tossing and turning.

How Light Exposure Shifts Your Clock

Light is the single most powerful signal your circadian clock receives. Bright light in the morning anchors your rhythm and helps you feel alert. But light at the wrong time, particularly in the evening, delays melatonin release and pushes your sleep window later.

Not all light is equal. The short-wavelength blue light in the 446 to 477 nanometer range suppresses melatonin more potently than other colors. This is the dominant wavelength emitted by phone screens, tablets, and LED monitors. Research shows that narrowband blue LED light may be more effective at suppressing melatonin than the standard white fluorescent lighting used in most offices and homes, and the effect is dose-dependent: brighter screens held closer to your face for longer periods cause more suppression. Dimming screens, using warm-toned night modes, or simply putting devices away an hour or two before bed can make a noticeable difference.

Caffeine and Adenosine

Caffeine is the most widely consumed sleep-disrupting substance on the planet, and it works by directly blocking the adenosine receptors in your brain. Instead of feeling the mounting sleepiness that adenosine normally creates, you feel alert because caffeine is sitting in those receptors, preventing adenosine from doing its job. The sleep pressure is still building, but you can’t feel it until the caffeine wears off.

The average half-life of caffeine in a healthy adult is about five hours, meaning half the caffeine from your 3 p.m. coffee is still circulating at 8 p.m. Individual variation is wide, though, ranging from 1.5 to 9.5 hours depending on genetics, liver function, and other factors. If you’re sensitive to caffeine or struggling with sleep, cutting it off by early afternoon gives your body enough time to clear most of it before bed.

What Alcohol Does to Sleep Stages

Alcohol is deceptive. It shortens the time it takes to fall asleep and increases deep sleep in the first half of the night, which can make it feel like a useful sleep aid. But the second half of the night tells a different story. As your body metabolizes the alcohol, sleep becomes fragmented: you spend more time awake, sleep efficiency drops, and the deep sleep you gained earlier disappears.

Alcohol also delays and reduces REM sleep, the stage associated with dreaming, memory consolidation, and emotional processing. REM normally accounts for about 25% of total sleep time across four to six 90-minute cycles per night. After drinking, REM is suppressed in the first half of the night, and unlike deep sleep, it doesn’t rebound in the second half. The net result is fewer total minutes of REM sleep overall. Even moderate drinking in the evening can produce this pattern.

Stress and the Cortisol Problem

Cortisol, your body’s primary stress hormone, follows its own daily rhythm. Levels normally peak in the morning to help you wake up and drop to their lowest point around midnight. Chronic stress, anxiety, or shift work can flatten or invert this pattern, leaving cortisol elevated at night when it should be low.

Elevated nighttime cortisol directly suppresses melatonin production, delaying sleep onset and increasing the number of times you wake during the night. This creates a frustrating cycle: poor sleep raises cortisol the next day, and higher cortisol makes the following night’s sleep worse. Practices that lower physiological arousal before bed, such as slow breathing, meditation, or even a consistent wind-down routine, work partly by helping cortisol settle into its normal nighttime trough.

Bedroom Temperature

Your body needs to drop its core temperature by about one to two degrees to initiate sleep. A warm room fights this process. Sleep specialists recommend keeping your bedroom between 60 and 67°F (15 to 19°C). This range supports the natural temperature decline your body needs and helps you stay asleep through the night. A room that’s too cold can also be disruptive, but most people err on the side of too warm, especially with heavy blankets or a partner sharing the bed.

Exercise Timing and Intensity

Regular physical activity is one of the most consistent sleep improvers in research. Morning exercise, in particular, tends to reinforce circadian rhythm and improve sleep quality. The picture gets more complicated with evening workouts. Evening exercise can delay your melatonin rhythm and raise core body temperature during the hours when it should be falling, both of which can interfere with falling asleep.

Intensity matters more than most people realize. High-intensity interval training performed in the evening has been shown to worsen sleep quality compared to lower-intensity activity done at the same time. One study in postmenopausal women found that those who exercised in the evening for more than 225 minutes per week over 12 months had a higher risk of trouble falling asleep. Moderate exercise, like a walk or gentle yoga, is less likely to cause problems close to bedtime. If you prefer intense workouts, finishing at least two to three hours before bed gives your body time to cool down and shift into recovery mode.

Diet and Nutrient Gaps

What you eat influences sleep through several pathways. Heavy meals close to bedtime can cause discomfort and acid reflux, both of which fragment sleep. But certain nutrients also play a more direct role.

Magnesium enhances the activity of your brain’s main calming neurotransmitter, reducing neuronal excitability and promoting relaxation. Clinical trials suggest that magnesium supplementation can improve sleep efficiency and reduce insomnia severity, potentially by boosting melatonin and lowering cortisol. A recent randomized trial found that 250 mg of elemental magnesium taken daily for 28 days produced modest but statistically significant improvements in insomnia symptoms in adults who reported poor sleep.

Glycine, an amino acid found in bone broth, meat, and some supplements, works through a different mechanism. It acts as an inhibitory neurotransmitter and helps lower core body temperature, which as noted above is a key trigger for sleep onset. Studies suggest that 3 grams of glycine before bed can improve subjective sleep quality and reduce next-day fatigue.

How Sleep Cycles Explain Why Disruptions Matter

A full night’s sleep consists of four to six cycles, each lasting roughly 90 minutes. Within each cycle, you move through light sleep (stages N1 and N2), deep sleep (N3), and REM sleep. The proportions shift across the night: deep sleep dominates the first half, while REM periods grow longer toward morning. About 75% of total sleep time is spent in non-REM stages, with the largest chunk (around 45%) in the N2 stage.

This architecture explains why different disruptions have different consequences. Alcohol, for instance, steals from your REM-heavy second half. Stress-driven awakenings in the early morning hours cut into your longest REM periods. A too-warm bedroom raises your core temperature enough to pull you out of deep sleep. And caffeine consumed too late doesn’t just delay sleep onset; it reduces the total amount of deep sleep you get even after you do fall asleep. Each factor hits a different part of your sleep architecture, which is why fixing just one issue sometimes isn’t enough to feel rested.