Coffee and Crossfit fitness go hand in hand, from plain old drip coffee to the infamous “bulletproof” brew popular with the Paleo crowd. Why is coffee so popular? There are many reasons, not the least of which is that coffee—thanks to its caffeine content–can have a positive effect on your performance.

What Caffeine Does in Your Body

Your brain is full of receptors with a chemical called adenosine, which slows down your nervous system and promotes sleep. This chemical circulates through your body constantly, plugging itself into receptors throughout the day like plugging electric cords into outlets. When enough of it is plugged in, you get sleepy.

Caffeine acts by binding to these same receptors, taking the place of adenosine. Instead of slowing down and getting sleepy, your body and brain speed up. The neurons in your brain fire faster, improving your focus and accuracy. Most importantly from an exercise standpoint, this chemical process provokes the “fight or flight” response.

Fight, Flight, or Crossfit

As caffeine binds to adenosine receptors and neurons in your brain fire faster, your pituitary gland takes notice and assumes there’s an emergency. This kick-starts the “fight or flight” response. Your body releases adrenaline, letting you work harder and faster. Your bronchial tubes dilate, letting you breathe more deeply and increasing your oxygen intake. Your pupils dilate, your heart rate rises—getting oxygen where it needs to go faster–and your liver releases sugar into your bloodstream, providing extra energy for your muscles. You’re poised to run, defend yourself…or tackle the WOD.

In the sports world, caffeine is actually recognized as a performance-enhancing drug. Before the 2000 Olympics, “excessive use,” meaning about 8 cups of regular coffee, was banned by the International Olympic Committee. And although the ban was overturned by the World Anti-Doping Agency in 2004, caffeine use is still monitored.

Your morning java is powerful stuff.

Less Pain, More Gain

Caffeine does more than let you work harder, faster, and longer. It also improves your focus and accuracy, an important component of Crossfit exercises. It also helps burn fat. Not only does it encourage your body to use fat—rather than glycogen—as an energy source, it boosts your metabolism so you burn more calories throughout the rest of the day.

Caffeine can also reduce pain, both during and after a workout. A 2007 study found that caffeine equivalent to 2-3 cups of coffee taken an hour before working out reduced the perception of pain during the workout and cut post-workout soreness by nearly half. Caffeine after a workout also has its benefits. Mixed with carbs, post-workout caffeine helps replenish muscle glycogen faster.

How Much Should You Drink?

That depends on who you ask. There is no ideal number of cups to drink. Each body is different, and people metabolize caffeine at different rates. However, most studies suggest that the optimal amount is between 3 milligrams and 6 milligrams per kilogram of body weight; this works out to two or three cups of coffee for a person weighing 150 pounds.

What experts do agree on is that the ideal time to drink coffee, if you’re looking to enhance your workout, is about an hour before you start. Studies also show that after a point, higher doses are no more effective than lower ones. In addition, when you indulge too much in caffeinated drinks, over time you build up a tolerance and need ever-larger doses to achieve the same effect.

As with most things diet-related, moderation is the key. Drinking two or three cups of coffee before a workout can be beneficial, but 4 or more cups isn’t necessarily better.