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 runs in ~90-minute cycles, each with 4 stages that do different jobs
  • Deep sleep (N3) handles physical repair — your body front-loads it in the first few cycles
  • REM sleep processes emotions and locks in memories — it stacks up toward morning
  • Waking mid-cycle triggers sleep inertia, that disoriented zombie state
  • The 90-minute rule is why 7.5 hours can feel better than 8

I used to run on 4 hours a night. For years. I wore it like a badge — "sleep is for the weak" was basically my personal motto. Then at 31 I hit a wall so hard I couldn't debug a simple for loop. That's when I started actually reading about what sleep does, and it turns out I'd been treating the most complex process in my body like a power switch: on or off.

It's not. Sleep has architecture. Stages, cycles, timing dependencies — honestly it reminds me of a build pipeline more than anything else. And once I understood the pipeline, I finally understood why I'd feel wrecked after 8 hours but sharp after 7.5. Why some mornings I couldn't remember my own address. Why my buddy who slept "less" than me somehow functioned better.

01 The Architecture of Sleep

Your brain doesn't just shut down for 8 hours. It runs the same program on a loop — roughly 90 minutes per iteration, though Carskadon and Dement's textbook work notes the real range is 80-120 minutes depending on the person[1]. Each loop is one sleep cycle.

A 7.5-hour night gives you about 5 cycles. But here's the part that changed everything for me: the cycles aren't identical. The mix of sleep stages shifts as the night goes on. Early cycles are heavy on deep sleep. Later ones are heavy on REM. Cut the night short on either end and you lose different things.

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

Four stages. Each does something different. I'll keep this at the "enough to be useful" level — you don't need to know about thalamocortical spindle generation to set a better alarm.

N1

Stage 1: The Doorway

~5% of night 1-5 minutes

The crossover point. Brain waves decelerate from active beta to alpha, then theta. Muscles start relaxing. This is where hypnic jerks happen — that sudden falling sensation that snaps you awake.

Function: Just the on-ramp. You wake easily from N1, which is why a 5-minute nap feels like nothing happened.
N2

Stage 2: Light Sleep

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

Actual sleep starts here. Heart rate drops. Body temp falls. Eyes stop moving. Your brain fires off sleep spindles — short bursts of fast activity — and K-complexes, big waves that basically tell the outside world to go away.

Function: Those sleep spindles are doing real work. Rasch and Born (2013) showed they're how your brain moves information from short-term into long-term storage[2]. This is the "save to disk" stage.
N3

Stage 3: Deep Sleep

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

This is the heavy maintenance window. Brain waves crater to delta frequency (0.5-2 Hz). Blood pressure drops, breathing slows way down, muscles go fully slack. Try waking someone from N3. They won't know where they are.

Function: Physical repair, immune support, growth hormone release. A 2013 paper in Science by Xie et al. also found the brain flushes metabolic waste during this stage — including amyloid-beta, the protein linked to Alzheimer's — via the glymphatic system[3].
REM

REM Sleep

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

Here's where it gets weird. Your brain ramps back up to near-waking activity levels. Eyes dart around under your lids. Vivid dreams happen. Meanwhile your body is paralyzed — a state called atonia — so you don't physically act out whatever your brain is simulating.

Function: Emotional processing and memory integration. Walker and van der Helm (2009) found that REM essentially strips the emotional charge from memories while keeping the content[4]. Think of it as your brain's garbage collector for emotional baggage.
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

The 90-minute rule is everywhere now. Plan your sleep in multiples of 90 minutes — 4.5, 6, 7.5, 9 hours — so you wake between cycles instead of in the middle of one.

Simple enough concept. But why does it actually matter? One word: sleep inertia. That's the clinical term for waking up and not knowing what year it is.

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

Tassi and Muzet's review in Sleep Medicine Reviews (2000) found that waking from N3 can impair cognitive performance for up to 30 minutes. In some measurements, the impairment was worse than being legally drunk[5]. That landed with me. I'd been waking from deep sleep for years and blaming coffee for not working fast enough.

"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

I need to be honest about something: 90 minutes is an average. Your actual cycles vary. First cycle might run 100 minutes. Fourth cycle might be 80. There's no universal constant here.

That's exactly why our sleep calculator gives you a range of wake times instead of one magic number. It also accounts for sleep onset latency (about 14 minutes on average to actually fall asleep). The goal isn't perfection — it's getting you close enough to a cycle boundary that your alarm doesn't rip you out of N3.

04 Sleep Pressure and Circadian Rhythm

Cycles are the what. But there are two systems controlling the when: sleep pressure (researchers call it Process S) and your circadian rhythm (Process C). Get these wrong and it doesn't matter how perfectly you calculated your bedtime.

Process S: Sleep Pressure

Adenosine accumulates in your brain from the moment you wake up. More hours awake = more adenosine = more sleepy. Caffeine blocks the adenosine receptors, which is why it doesn't actually fix tiredness — it just hides the signal.

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

Process C: Circadian Rhythm

Your 24-hour internal clock, run by the suprachiasmatic nucleus (SCN). It triggers melatonin when it gets dark and cortisol when it gets light. This is what sets your natural sleep window.

Key insight: There's a natural dip around 2-3pm (the post-lunch slump is real, and it's not just your burrito) and another around 2-4am.

When both systems line up — high adenosine pressure hits at the same time as your circadian low — you fall asleep fast and cycle cleanly. When they're fighting each other (like trying to crash at 8pm after a late afternoon nap), you get fragmented garbage sleep no matter how many hours you're in bed. I learned this one the hard way during my "I'll just nap at 6pm and go to bed at midnight" phase.

05 Practical Application

That's the science. Now let me show you what to do with it.

Calculate Your Wake Time

The math is straightforward. Start with when you need to be up. Count backward in 90-minute blocks. Add about 15 minutes for falling asleep. Those are your target 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

Protect your early-night sleep. Deep sleep is concentrated in cycles 1 and 2. If you have to cut hours somewhere, go to bed on time and set an early alarm — don't stay up late.

Best for: Athletes, post-workout recovery, fighting off sickness

For Learning & Memory

You need the full night. N2's memory-consolidation spindles fire all night long, and REM integration happens in the later cycles. Pulling an all-nighter before an exam is literally counterproductive.

Best for: Exam prep, learning a new codebase, studying

For Emotional Processing

Don't sacrifice your morning sleep. REM dominates cycles 4 and 5. If you're dealing with stress, that last hour before your alarm is doing more than you think.

Best for: After a bad week, creative work, working through problems

For Daytime Alertness

Wake between cycles, not during one. A sleep calculator gets you close. A smart alarm that detects movement (lighter sleep = more micro-movements) gets you closer.

Best for: Anyone who has ever hit snooze 11 times

The Napping Exception

Naps play by different rules. The key constraint: don't drop into deep sleep unless you have 90 minutes to complete the full cycle. Otherwise you'll wake up worse than before.

10-20
Power Nap

Stays in N1-N2 territory. You get a real alertness bump without the inertia hangover. Set your alarm. Don't negotiate with it.

30
Danger Zone

You drop into N3 but don't finish it. Your alarm drags you out of deep sleep and you feel actively worse. Avoid this range unless you're running on serious sleep debt.

90
Full Cycle

A complete cycle with REM. You wake up actually refreshed. Good for paying down sleep debt, but it can mess with your bedtime later — use sparingly.

Why This Matters for Your Alarm Clock

When I was sleeping 4 hours a night, I thought the problem was quantity. It wasn't — or at least, it wasn't only that. I was setting alarms at random times, ripping myself out of deep sleep, then wondering why six cups of coffee couldn't fix the fog. Understanding cycles didn't just change when I sleep. It changed how I think about sleep entirely.

The practical version is simple: try to wake between cycles, not in the middle of one. That's the whole reason I built the sleep calculator — it does the 90-minute math for you and accounts for the time it takes to fall asleep. The difference between landing on a cycle boundary versus getting yanked out of N3 is the difference between "okay, I can function" and "I genuinely cannot remember my own phone number." I've been on both sides. The cycle boundary side is better.

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