No company better defines the e-commerce industry than Amazon (AMZN 3.20%), the online retail giant that commands about half of online sales in the U.S. A close second may be Shopify (SHOP 2.27%), whose cloud-based platform powers the software behind many of the small and medium-sized business that sell online.

E-commerce has proven itself to be a huge, long-tail growth market, with U.S. e-commerce sales growing about 15% annually since the financial crisis, yet it still accounts for less than 10% of total retail sales. Nevertheless, Amazon and Shopify stocks have both electrified the market. Amazon has been the best-performing stock over the last generation, gaining a whopping 85,000% since its 1997 IPO, and Shopify is no slouch either, having returned nearly 700% since it debuted in 2015 -- even outperforming Amazon over that time frame, as the chart below shows.

SHOP Chart

SHOP data by YCharts

The similarities don't end there. Both have a history of generating losses as they have invested to gain market share, though Amazon has recently shifted to profitability thanks largely to the success of Amazon Web Services, its cloud computing division. Given their impressive histories of growth and the potential of e-commerce, investors looking for exposure to e-commerce may have trouble choosing between the two. Let's take a closer look at both stocks in order to determine which is the better buy today.

A man ordering a pair of shoes online

Image source: Getty Images.

Unstoppable growth 

With the exception of several months of volatility last year, Shopify shares have been rising almost constantly since they first hit the market in 2015. The stock is already up 45% this year, and it just topped $200/share for the first time ever.

Few stocks have delivered the kind of top-line growth that Shopify has throughout its history. Revenue jumped 59% last year to $1.07 billion, and gross merchandise volume (GMV), or the total value of the goods sold on its platform, rose 56% to $41.1 billion. 

Shopify's growth is steadily moderating, however, coming in at only 54% in the fourth quarter, its slowest quarterly growth as a publicly traded company -- and the company sees revenue rising only 36%-38% over the next year. Shopify is not profitable on a GAAP basis, but delivered an adjusted profit of $39.2 million, or $0.38 a share, last year as it spent more than $95 million on stock-based compensation.

Shopify's service has clearly resonated with the SMBs, which make up the majority of its sellers. They use its tools to manage their businesses across multiple channels, and do things like accept payments and assist with shipping. 

Through its four subscription levels -- Basic, Shopify, Advanced, and Plus -- Shopify's services scale up with its customers' needs, allowing it to grow with them.  Shopify's most valuable customers are its more than 5,300 Shopify Plus subscribers, including Unilever, Allbirds, and Kylie Cosmetics, which pay between $2,000 and $40,000 a month for the service. In the fourth quarter, Shopify Plus subscribers contributed $10.4 million in monthly recurring revenue, or 25% of total MRR, up from 21% a year ago. 

Check out the latest earnings call transcript for Amazon and Shopify.

Dominating e-commerce and more

Though Amazon is best known for its e-commerce prowess -- more than 100 million people around the world subscribe to its Prime loyalty program -- the company is much more than just an online retailer. AWS is its most profitable and fastest-growing business segment, delivering $7.3 billion in operating profit on $25.6 billion in revenue, up 47% from the year before. AWS rivals Microsoft'sAzure for title of biggest cloud service in the world.

Meanwhile, Amazon is investing heavily in areas like voice-activated technology through Alexa as well as logistics and shipping, and it continues to expand its brick-and-mortar presence. Less than two years after acquiring Whole Foods, the company is reportedly seeking to launch its own banner of grocery stores, and could expand the nascent Amazon Go chain, its cashierless convenience store concept, to as many as 3,000 stores. It also seems to be focused on establishing more of a permanent presence in malls beyond its handful of Amazon Books and 4-Star stores, as it just announced it would close all 87 of its pop-up locations. Amazon is also leveraging its market power by building its higher-margin marketplace and fulfillment service, and has even stopped ordering from some major vendors, instead telling them to sell directly to customers on Amazon's marketplace.

Like Shopify, however, Amazon has seen its once-blockbuster growth rate cool off. In its most recent quarter revenue increased 20% to $72.4 billion, and the company finished the year with $232.9 billion in revenue, making it one of the biggest companies in the world by sales. However, the company expects revenue to grow just 10%-18% in the first quarter, though it sees stronger growth in operating profit.

It's hard to doubt Amazon's massive market power, but the question for investors at this point seems to be if the company can shift from revenue growth to profits fast enough to justify further share appreciation.

Who wins this e-commerce war? 

As you might expect from stocks with strong growth rates, both stocks trade at lofty valuations. Amazon trades at a P/E of 83, while Shopify is valued at a P/E of 527. In other words, investors expect significant profit growth from both companies.

Perhaps the biggest difference between these two companies is their size. Amazon is one of the biggest companies in the world at a market cap of $820 billion, while Shopify is valued at just $22 billion.

Given Amazon's size, it will be harder for the stock to deliver the kind of blockbuster growth that both stocks have posted in the past. At only $22 billion, Shopify has much more room to double or triple its value. However, Shopify's business, which is concentrated in one industry and sensitive to the vulnerabilities of its merchants and therefore the broader economy, is significantly riskier than Amazon's. Considering Shopify's valuation, the stock is also more at risk of a recession or other kind of market sell-off.

Therefore the better buy here may come down to investing style: More risk-averse investors would be better off with Amazon over Shopify, while investors with higher risk tolerance may prefer Shopify. Over the long-term, I think Shopify is more likely to outperform Amazon given its greater growth potential, its leadership position in its industry, and its direct exposure to its market; however, the stock is also more at risk of a sell-off in the shorter term.