Elon Musk had to quit this common bad habit before he became successful

Elon Musk stands beside a rocket March 19, 2004 in El Segundo, Los Angeles, California.

As Tesla founder Elon Musk pushes to deliver the Model 3 cars to buyers, he's taken to pulling all-nighters and sleeping on the company floor.

Though the serial entrepreneur has experience working long hours and under pressure, Musk admits that he had to overcome one bad habit on the road to success: drinking large amounts of caffeinated beverages.

"There were probably times when I had like eight [diet cokes] a day or something ridiculous," Musk told the German automobile magazine Auto Bild in 2014. "I think these days it's probably one or two, so it's not too crazy."

However, coffee was also an addiction for the billionaire. "I used to have so much coffee...that I'd get really wired," he said. "I'd get over-caffeinated and it wouldn't be good."

Musk has since cut back to more "reasonable portions," which at the time was two cups of coffee a day. But the tech billionaire isn't alone when it comes to caffeine consumption.

A recent survey from the National Coffee Association found Americans are drinking coffee at the highest level in six years. Sixty-four percent of adult Americans say they had a cup of coffee the previous day in 2018, up from 62 percent in 2017.

Meanwhile, diet soda consumption has been on the decline. A Gallup poll found that 24 percent of Americans drink diet soda and 44 percent drink soda overall. However, a majority of Americans say they try to avoid drinking soda.

La Colombe Coffee

Although medical experts disagree on whether coffee is beneficial to your health, almost all agree that drinking diet coke and ingesting too much caffeine is detrimental to your well-being.

Researchers at Boston University School of Medicine found that people who consume diet soda daily are three times more likely to suffer from a stroke or dementia within the next ten years. Additionally, the artificial sweetener aspartame that is found in most diet sodas has been linked to migraines, irritable moods, anxiety and insomnia.

Healthcare experts also warn against drinking high amounts of caffeine. Research shows that relying on high amounts of coffee creates this toxic cycle: tiredness, which leads to increased coffee consumption, which impairs your sleep, which leads to "daytime fatigue the next day," which leads to more coffee consumption. One study found that even modest amounts of coffee may "significantly" increase stress levels and anxiety when consumed in a short time period.

Still, coffee-lovers like Musk shouldn't fret just yet. An analysis by The European Food and Safety Authority found that up to 400mg of caffeine a day, roughly four standard size cups of joe, appears to be safe for most healthy adults. Additional studies have even found that drinking moderate amounts of coffee can enhance your memory performance and improve mental function.

As for Musk, he told Auto Bild that he swapped his caffeinated drinks for some good ol' H2O.

Like this story? Like CNBC Make It on Facebook.

Don't miss: Bill Gates had to quit this common bad habit before he became successful

This is how Tesla CEO Elon Musk stays productive
This is how Tesla CEO Elon Musk stays productive