Getting in on the right stock early can make all the difference in the world for your retirement. But how do you identify a potential millionaire-making stock?

While looking for companies that turned a small investment into a large sum, I've noticed two basic characteristics millionaire-making stocks have in common.

First, these stocks tend to grow revenue consistently fast in the early years. That might be stating the obvious, but if you want to build wealth through stocks, you've got to invest in growth. One dollar compounded at 20% for 30 years turns into $237. Start with $10,000 and that turns into $2.37 million.

The second thing, which explains why the company is growing fast, is that great growth stocks have a massive market to expand into. Some companies only grow fast for a while before they run out of room to expand due to competition or limited markets for their products. You want to find companies that have mass appeal for the service provided.

Two stocks that met those criteria and turned a small investment of $1,000 into more than a million bucks are Walmart (NYSE:WMT) and Amazon.com (NASDAQ:AMZN).

A man, wearing black sunglasses, tosses dollar bills out of his hand.

Image source: Getty Images.

1. Walmart

Sam Walton started from humble beginnings with a single discount store in the town square of Bentonville, Arkansas, in 1950. Seasoned retail veterans thought Walton's idea to build a successful retail store around the concept of offering the lowest possible prices would never work. The first dime store was so successful that Sam Walton opened a new store, the first Walmart, in 1962 in Rogers, Arkansas.

Walmart first sold shares to the public in 1970 at $16.50 per share. There have been 11 stock splits, all 2-for-1, so a single share purchased in 1970 would have turned into 2,048 shares.

Assuming fractional shares existed in 1970 (many brokers now offer this), a $1,000 investment would have bought 60.606 shares. Adjusting for splits, that investment would be worth $16 million at the current stock price of approximately $129.

In 1970, Walmart generated just $30.8 million in annual sales. By 1980, sales had climbed to $1 billion, making Walmart the fastest company to reach $1 billion in annual sales at the time.

Walmart has been outpaced by Amazon in recent years, but it's still a strong company, with $524 billion in sales last year, and it continues to grow. CEO Doug McMillon took over in 2014 and has pushed Walmart aggressively into e-commerce by partnering with JD.com in China and acquiring Jet.com and Flipkart in India, among other deals. Last year, Walmart launched NextDay Delivery to more than 75% of the U.S. population. E-commerce sales grew 35% year over year in the fiscal fourth quarter.

Walmart stock has been hitting new highs during the COVID-19 outbreak. Stores are experiencing strong demand, which prompted the company to announce the hiring of 150,000 new workers and a pledge to hire 50,000 more in the short term.

AMZN Chart

AMZN data by YCharts.

2. Amazon.com

Amazon was incorporated in 1994 and opened for business online in 1995. Founder and CEO Jeff Bezos essentially created a digital version of the Sam Walton model: Sell everything at competitive prices and offer unrivaled customer service.

But Amazon had the advantage of being a first-mover since Walmart didn't launch an e-commerce site until 2000. By then, Amazon was already becoming synonymous with online shopping and had $2.7 billion in annual sales and was growing fast. Back then, if you wanted a book but didn't mind waiting a week to receive it via snail mail, you didn't go to Walmart.com; you went to Amazon.

As Amazon dominated online media sales, such as books and CDs, it was building a massive loyal customer base, so that by the time other retailers woke up and realized they needed to get with the program, it was too late. Amazon was cornering the market for e-commerce and was reinvesting all gross profit into expanding selection and technology and mapping the country with warehouse shipping facilities.

Amazon had its IPO in May 1997 at $18 per share. A $1,000 investment would have purchased 55.56 shares. After three stock splits, you would have 666.72 shares worth $1.6 million at the current stock price of approximately $2,400.

Amazon has come a long way over the last 20 years. Cash from operations has grown from $174 million in 2002 to $38.5 billion in 2019. As the cash poured in, Amazon expanded into all kinds of new product categories, which has only widened its moat over the years. It introduced the Kindle e-reader in 2007 and later rolled out the Kindle Fire tablet and Fire TV stick. Its Alexa voice assistant for Echo devices has been widely used by customers.

These products deepened customer relationships with the Amazon ecosystem of services, building its brand, and making it easier for customers to shop.

Growth in cloud services has had a significant impact on Amazon's business lately. Amazon Web Services makes up two-thirds of Amazon's operating income. But other businesses Amazon is developing could potentially be even more impactful on revenue growth, such as business-to-business commerce, advertising services, and Amazon's efforts to win the last-mile delivery race with its own courier fleet, going head to head with UPS and FedEx.

Amazon's Whole Foods Market and Amazon Fresh grocery delivery services have been swamped with demand in recent weeks. E-commerce has been growing for 25 years, but about 85% of retail sales worldwide still occur in a store somewhere. The COVID-19 crisis will likely encourage even more people to become comfortable shopping for food online, and that could have a big impact on Amazon's momentum.