If you have a nest egg of $50,000 saved towards retirement, but with quite a way out to actual retirement, and you're also thinking of investing it in the stock market, you can potentially make some serious gains in the long run. And while the markets might seem shaky right now, you don't have to worry about taking on significant risk in order to grow your portfolio to $1 million or more.

Below, I'll outline the path to increasing your savings over the long term and possibly get your portfolio to $1 million by the time you retire.

Focusing on growth stocks is still a great idea

Many investors might be nervously watching the market's recent decline, worried about whether investing in growth stocks is still a good idea.

But even if the market crashes for several weeks, months, or even a year, that time frame will most likely be too short in the grand scheme of things if you plan to remain invested in the stocks for decades. And if you're investing for retirement and looking at a buy-and-hold approach, it's going to be crucial to have the coolheaded temperament to avoid rash decisions when the markets appear to be in free fall.

As long as you don't think you'll need to pull your money out within the next few years, the best decision will likely be to do nothing and stay the course.

Investing in growth stocks can result in significant gains in the long run. And rather than picking stocks individually, what can be optimal for many investors is to load up on exchange-traded funds (ETFs) to diversify and gain a position in dozens, potentially hundreds, or even thousands of stocks.

One ETF that screams "growth" is the Invesco QQQ Fund (QQQ 2.71%). It tracks the Nasdaq 100 index, which includes the largest nonfinancial stocks on the Nasdaq exchange.

Microsoft, Nvidia, and many other big names are in there. And the best part: It will make adjustments, so you don't have to. As Nasdaq stocks rise in value and become among the most valuable, they'll be included in the index, and you'll have a position in them through this ETF. And underperforming stocks will be removed.

It's hard to go wrong with the fund. Over the past 20 years, it has eclipsed the gains of the S&P 500.

QQQ Chart
QQQ data by YCharts.

You'll notice that the Invesco ETF's impressive returns even factor in this latest rout in the stock market. Before this, its 20-year gains were comfortably over 1,000%.

But it's important to remember that the past doesn't predict the future, and there could very well be more-modest gains ahead for the Invesco fund given the elevated valuations of many tech stocks. But odds are, it can still outperform the S&P 500 in the long run.

The path to $1 million

Based on the ETF's 960% gain over the past 20 years, it has averaged a compound annual growth rate of 12.5% during that stretch. But given the possibility of a slowdown in the markets, it might be wise to be more modest and assume a slower average growth rate, perhaps between 9% and 10%. Here's how a $50,000 investment in the Invesco fund could grow under those circumstances.

Future Balance If You Invest $50,000 Today

Years CAGR of 9%  CAGR of 10%
5 $76,931 $80,526
10 $118,368 $129,687
15 $182,124 $208,862
20 $280,221 $336,375
25 $431,154 $541,735
30 $663,384 $872,470
35 $1,020,698 $1,405,122

Calculations and table by author. CAGR = Compounded Annual Growth Rate.

If you put $50,000 into the Invesco ETF, you can end up with $1 million within 30 to 35 years, depending on what your actual average return ends up being. And this doesn't account for reinvested dividends, either, which will pad your returns a bit.

However, with a yield of around 0.6%, dividends will likely play only a minor part of the growth behind this fund. The big gains are going to come from capital appreciation and rising stock valuations.

The Invesco QQQ Trust can be just one of many diversified investments in your portfolio to benefit from the stock market's long-run gains. The keys are to remember to focus on growth and avoid the temptation to pull money out of your portfolio unless you think you'll need it within the next five years.

Otherwise, staying the course, even if the situation might look troubling, could be your best move. After all, the market has always recovered.