In case you haven't heard, there really is no such thing as an overnight success. Breakout hits are almost always followed by years of toil and failure.

Angry Birds was Rovio's 52nd attempt. Elon Musk studied battery technology for more than a decade before starting Tesla. Twelve foolish publishers turned down J.K. Rowling's Harry Potter manuscript before someone agreed to pay her an advance of just £1,500 for the book that would become an international blockbuster.

I could go on. But the point is clear: The road to success is almost always long and winding. How do you stick with your dreams and keep your motivation up despite this punishing fact?

Writing on his blog recently, James Clear offers a simple, science-backed answer to this question. All you need to do is just follow one straightforward rule, he says.

The Goldilocks Rule

"Scientists have been studying motivation for decades. While there is still much to learn, one of the most consistent findings is that perhaps the best way to stay motivated is to work on tasks of 'just manageable difficulty,'" Clear explains, offering tennis as an example.

Play against a 4-year-old and you'll quickly grow bored. Play against Roger Federer and you'll just as quickly become discouraged. You need an opponent that's just a bit better than you.

"We can call this phenomenon The Goldilocks Rule," he says. "The Goldilocks Rule states that humans experience peak motivation when working on tasks that are right on the edge of their current abilities. Not too hard. Not too easy. Just right."

Not only will finding this difficulty sweet spot keep you motivated, it'll also make you happier. Clear quotes psychologist Gilbert Brim to back up this point: "One of the important sources of human happiness is working on tasks at a suitable level of difficulty, neither too hard nor too easy."

Measure your progress

Say you're sold on the idea of the Goldilocks Rule. How do you apply it in real life? The answer will depend, of course, on the domain in which you're trying to be successful. If you want to get fitter, it means finding workouts that challenge but don't exhaust you. If you're hoping to start a world-beating business, it entails finding ways to push yourself to acquire the sales and business skills you'll need bit by bit.

But no matter what you're trying to accomplish, Clear offers one more bit of advice on how to put the Goldilocks Rule into action. "In order to reach this state of peak performance, however, you not only need to work on challenges at the right degree of difficulty, but also measure your immediate progress," he adds, concluding:

"The human brain needs some way to visualize our progress if we are to maintain motivation. We need to be able to see our wins." So on the long road to success, don't just count the potholes of failure that jolt you on your journey. Also make sure to keep a tally of the skills you've mastered and the progress you've made.

Are you hitting the personal challenge sweet spot--enough to engage, but not so much as to discourage?