Advertisement
Science 12 min read

Sleep Cycles Explained: What Actually Happens When You Sleep

A developer's guide to understanding the architecture of sleep

Kevin Li
Kevin Li Software Developer, Former Insomniac
Published
Abstract visualization of sleep waves in dark blue gradient

Key Takeaways

  • Sleep happens in ~90-minute cycles, each containing 4 distinct stages
  • Deep sleep (N3) is when your body physically recovers—it dominates early cycles
  • REM sleep processes emotions and consolidates memories—it increases toward morning
  • Waking mid-cycle causes sleep inertia (that groggy, "hit by a truck" feeling)
  • The 90-minute rule helps you time wake-ups for maximum alertness

When I was grinding through 18-hour coding sessions, I thought sleep was binary: you were either asleep or awake. Turns out sleep is more like a complex algorithm with multiple nested loops—and understanding the code changed how I approach rest entirely.

This isn't just academic. Knowing how sleep cycles work lets you make smarter decisions: when to set your alarm, why you feel like garbage after 8 hours but great after 7.5, and what's actually happening when you dream about your teeth falling out (spoiler: it's REM processing stress).

01 The Architecture of Sleep

Think of a night's sleep as running a program multiple times. Each execution is one sleep cycle, lasting roughly 90 minutes (though it can range from 80-120 minutes depending on the person and conditions)[1].

In a typical 7.5-hour night, you'll complete about 5 cycles. But here's what most people don't realize: not all cycles are equal. The composition of each cycle changes throughout the night.

A Night of Sleep (Simplified)

Cycle 1
Light
Deep
REM
~90 min
Cycle 2
Light
Deep
REM
~90 min
Cycle 3
Light
Deep
REM
~90 min
Cycle 4
Light
Deep
REM
~90 min
Cycle 5
Light
REM
~90 min
Light Sleep (N1-N2) Deep Sleep (N3) REM Sleep

"The first half of the night is dominated by deep sleep, the second half by REM. Skip either end and you lose different functions."

— Dr. Matthew Walker, Why We Sleep

02 The Four Stages of Sleep

Let's break down what's actually happening in each stage. I'm going to keep this practical—you don't need a neuroscience degree, just enough to understand why each stage matters.

N1

Stage 1: The Doorway

~5% of night 1-5 minutes

The transition between wake and sleep. Your brain waves slow from active beta waves to relaxed alpha, then to theta. Muscle activity decreases. You might experience hypnic jerks (those falling sensations that wake you up).

Function: Gateway to deeper sleep. Easy to wake from— which is why you don't feel like you've slept if you only nap for 5 minutes.
N2

Stage 2: Light Sleep

~45-55% of night 10-25 minutes per cycle

True sleep begins. Heart rate slows, body temperature drops, eye movements stop. Your brain produces sleep spindles (bursts of rapid activity) and K-complexes (large waves that suppress response to stimuli).

Function: Sleep spindles are critical for memory consolidation and learning. This is when your brain transfers information from short-term to long-term storage[2].
N3

Stage 3: Deep Sleep

~15-25% of night 20-40 minutes (early cycles)

The restorative powerhouse. Brain waves slow dramatically to delta waves (0.5-2 Hz). Blood pressure drops, breathing slows, muscles fully relax. Very difficult to wake from—and if you do, expect disorientation.

Function: Physical recovery, immune function, growth hormone release. Your brain also clears metabolic waste (including amyloid-beta, linked to Alzheimer's) via the glymphatic system[3].
REM

REM Sleep

~20-25% of night 10-60 minutes (increases)

Rapid Eye Movement sleep. Your brain becomes almost as active as when awake (sometimes more). Eyes dart rapidly. Most vivid dreams occur here. Body is essentially paralyzed (atonia) to prevent acting out dreams.

Function: Emotional processing, creative problem-solving, memory integration. REM "divorces" emotional memories from their emotional charge[4].
50% of sleep is N2 light sleep
90% of deep sleep in first half of night
50% of REM in final third of night

03 Why 90 Minutes Matters

You've probably heard the "90-minute rule" for sleep. The idea is simple: plan your sleep in multiples of 90 minutes (4.5, 6, 7.5, or 9 hours) to wake at the end of a cycle rather than in the middle.

But why does this matter? The answer is sleep inertia—the grogginess, impaired cognition, and general "why am I even alive" feeling that occurs when you wake from the wrong stage.

Sleep Inertia by Stage

N1/N2 Light Sleep Minimal grogginess Clears in minutes
N3 Deep Sleep Severe disorientation Can last 30-60 min
REM REM Sleep Dream confusion Clears in 5-15 min

A study in the Journal of Sleep Research found that waking from deep sleep (N3) can impair cognitive performance for up to 30 minutes—sometimes more severely than being legally drunk[5].

"Sleep inertia from deep sleep can reduce cognitive performance by up to 50% for the first few minutes after waking."

— Tassi & Muzet, 2000

The Caveat

Here's the thing: the 90-minute rule is an approximation. Real sleep cycles vary from 70-120 minutes, and they change throughout the night. Your first cycle might be 100 minutes; your fourth might be 80.

That's why sleep calculators (like ours) factor in both the time to fall asleep (average 14 minutes) and provide a range of wake times rather than a single "perfect" moment.

04 Sleep Pressure and Circadian Rhythm

Understanding cycles is only half the equation. Two biological systems control when and how you sleep: sleep pressure (Process S) and your circadian rhythm (Process C).

Process S: Sleep Pressure

From the moment you wake, a chemical called adenosine builds up in your brain. The longer you're awake, the more pressure you feel to sleep. Caffeine works by blocking adenosine receptors—which is why it doesn't eliminate tiredness, just masks it.

Key insight: You need ~16 hours of wakefulness to build enough sleep pressure for quality sleep.

Process C: Circadian Rhythm

Your internal 24-hour clock, governed by the suprachiasmatic nucleus (SCN), releases melatonin in response to darkness and cortisol in response to light. It determines your natural sleep window.

Key insight: Your circadian rhythm dips naturally around 2-3pm (hence the afternoon slump) and again around 2-4am.

When these two systems align—high sleep pressure + circadian low point—you fall asleep easily and cycle efficiently. When they fight (like when you try to sleep at 8pm after napping at 5pm), you get fragmented, poor-quality sleep regardless of how many hours you spend in bed.

05 Practical Application

Okay, so you understand the theory. Here's how to actually use it.

Calculate Your Wake Time

Most sleep calculators work backwards from your desired wake time. Count back in 90-minute intervals, add ~15 minutes to fall asleep, and you get optimal bedtimes.

Example: 7:00 AM Wake Time
6 cycles (9 hrs) Bedtime: 9:45 PM
4 cycles (6 hrs) Bedtime: 12:45 AM
3 cycles (4.5 hrs) Bedtime: 2:15 AM Emergency only

These times include 15 minutes to fall asleep. Adjust based on your own sleep onset time.

Optimize Your Sleep Stages

For Physical Recovery

Prioritize early-night sleep. Deep sleep dominates cycles 1-2. If you must cut sleep short, go to bed at your normal time and wake up early rather than staying up late.

Best for: Athletes, after intense workouts, recovering from illness

For Learning & Memory

Get your full sleep. N2 light sleep (with those memory-critical sleep spindles) happens throughout the night. REM for integration comes later.

Best for: Before exams, learning new skills, studying

For Emotional Processing

Don't cut your morning sleep. REM dominates cycles 4-5. If you're processing stress or trauma, that extra hour in the morning matters.

Best for: After stressful events, creative work, problem-solving

For Daytime Alertness

Wake at the end of a cycle. Use a sleep calculator or a smart alarm that detects movement (lighter sleep stages involve more micro-movements).

Best for: Everyone who hates mornings (so, everyone)

The Napping Exception

For naps, the cycle rules change. You generally want to avoid entering deep sleep during a nap unless you have 90 full minutes.

10-20
Power Nap

Stay in N1-N2. Quick boost in alertness without sleep inertia. Set your alarm for exactly 20 minutes.

30
Danger Zone

You'll enter N3 but not complete it. Wake up feeling worse than before. Avoid 30-60 minute naps unless you're severely sleep-deprived.

90
Full Cycle

Complete a full cycle including REM. Wake up refreshed. Best for recovering from sleep debt, but may affect nighttime sleep.

The Bottom Line

Sleep isn't just unconsciousness—it's a complex, staged process where different things happen at different times. The 90-minute cycle is real, but individual variation means you'll need to experiment to find your optimal timing.

The most actionable takeaway: try to wake up at a cycle boundary. Use our sleep calculator to find your times, or try a smart alarm. The difference between waking from N2 versus N3 is the difference between feeling human and feeling like death.

Sources & Further Reading

  1. Carskadon, M. A., & Dement, W. C. "Normal Human Sleep: An Overview." Principles and Practice of Sleep Medicine, 6th ed. (2017) ScienceDirect →
  2. Rasch, B., & Born, J. "About Sleep's Role in Memory." Physiological Reviews, 93(2), 681-766. (2013) PubMed →
  3. Xie, L., et al. "Sleep Drives Metabolite Clearance from the Adult Brain." Science, 342(6156), 373-377. (2013) PubMed →
  4. Walker, M. P., & van der Helm, E. "Overnight Therapy? The Role of Sleep in Emotional Brain Processing." Psychological Bulletin, 135(5), 731-748. (2009) PubMed →
  5. Tassi, P., & Muzet, A. "Sleep inertia." Sleep Medicine Reviews, 4(4), 341-353. (2000) PubMed →

Recommended Resources

  • Why We Sleep by Matthew Walker, PhD
  • The Promise of Sleep by William Dement, MD
  • Huberman Lab Podcast: "The Science of Sleep"
Kevin Li
Written by

Kevin Li

Software Developer, Former Insomniac

Former 4-hours-a-night tech guy. Burned out at 31, spent two years fixing my sleep. Built this calculator because all the existing ones looked like they were made in 2005.

Advertisement 728x90
Advertisement