Many stocks have performed well this year, evidenced by the S&P 500's 20% year-to-date gain. But some stocks have managed to obliterate market index returns.

Here are three stocks -- Nvidia (NVDA -2.68%), Cloudflare (NET -2.42%), and MongoDB (MDB -1.12%) -- that have more than doubled the market's returns in 2021. More importantly, we'll look to see if they could go even higher over the long haul.

A chart showing a stock price moving higher.

Image source: Getty Images.

Nvidia

Shares of Nvidia have skyrocketed 74% this year, fueled by the graphics-chip maker's huge top-line growth and soaring earnings.

Interestingly, Nvidia's price-to-earnings ratio of 81 today is 5% lower than where it was at the start of the year -- despite the growth stock's surging price. That's because earnings have grown faster than the stock price. Consider the company's Aug. 18-reported fiscal second-quarter financial performance: Revenue grew 68% year over year and earnings soared 276% to $0.94 per share over the same period. 

Because of the stock's strong top- and bottom-line fundamentals, shares arguably remain attractive -- even after their run-up.

Cloudflare

Content delivery network specialist Cloudflare's stock is up 73% this year, similarly soaring past the S&P 500's 20% gain.

The company has impressed investors in 2021 with consistently high growth rates, even as Cloudflare faces tough year-ago comparisons. Consider how the company grew revenue 53% in its most recent quarter -- an acceleration compared to the 48% revenue growth it posted in the second quarter of 2020. The period was helped by a record number of large customer additions, with Cloudflare "signing the equivalent of more than two six-figure customers every single business day in Q2," said Cloudflare CEO Matthew Prince in the company's second-quarter earnings release.

But with Cloudflare still reporting losses, both on a generally accepted accounting principles (GAAP) and non-GAAP (adjusted) basis, the stock's pricier valuation isn't as easy to justify as it was at the start of the year. Nevertheless, it wouldn't be surprising to see shares perform well over the long haul, but there may be too much excitement priced into this stock to call it a buy at this level.

MongoDB

Cloud-based data specialist MongoDB's stock is up 39% this year, with much of this gain coming after the company's outstanding fiscal second-quarter results were announced last week. Like Cloudflare, MongoDB's top-line growth has been accelerating. Revenue grew 44% year over year in fiscal Q2 -- up from 39% growth both last quarter and in the year-ago period. 

MongoDB's hefty losses unfortunately make the outlook for the stock somewhat riskier than NVIDIA. Nevertheless, with strong top-line momentum and a scalable business model, shares are more likely to rise from here over the long haul than they are to fall. But investors may want to look for a more attractive entry point before they consider buying the stock.