Alibaba (BABA 0.28%) and Amazon (AMZN -2.56%), two of the world's top e-commerce and cloud infrastructure companies, have both generated multibagger returns for long-term investors.

Alibaba's stock has nearly quadrupled since its public debut in late 2014, while Amazon's stock delivered a near ten-fold gain during the same period. Let's see why the bulls stampeded toward the two tech titans, and whether or not they still have room to run in this unpredictable market.

Tiny parcels on a laptop keyboard.

Image source: Getty Images.

The differences between Alibaba and Amazon

Alibaba is often referred to as the "Amazon of China", but that nickname glosses over the two companies' fundamental differences.

Alibaba generates most of its revenue from its core commerce business, which includes its online marketplaces and brick-and-mortar stores. The rest of its revenue comes from its cloud, digital media, and innovation initiatives businesses.

Packages sitting in a warehouse.

Image source: Getty Images.

Alibaba's core commerce business is its only profitable segment. Those profits subsidize the expansion of its unprofitable businesses, which broaden its ecosystem and widen its moat against rivals like Tencent and Baidu.

Amazon also generates most of its revenue from its online marketplaces, but most of its profits come from its market-leading cloud platform, Amazon Web Services (AWS). AWS accounted for nearly a third of all cloud infrastructure spending worldwide at the end of 2019, according to Canalys. That superior scale enables AWS to operate at much higher margins than Alibaba Cloud, which remains a much smaller player in the global cloud market.

Therefore, Amazon subsidizes the growth of its lower-margin e-commerce marketplaces with its higher-margin cloud revenue. That strategy gives Amazon more room to constantly expand its ecosystem with Prime memberships, digital content, and brick-and-mortar stores.

Why is Alibaba's marketplace more profitable?

Alibaba generates higher-margin revenue from its core marketplaces (Tmall and Taobao) because it doesn't directly fulfill those orders with a first-party logistics network like Amazon or JD.

Instead, Alibaba's marketplaces mainly charge listing fees and commissions, which technically makes it an advertising platform, while merchants fulfill their own orders. Amazon fulfills its own first-party orders, but many of its third-party merchants ship their own products. As a result, Alibaba generates higher operating margins than Amazon:

BABA Operating Margin (TTM) Chart

Source: YCharts

However, Alibaba's investments in its ecosystem, along with its growing dependence on its lower-margin brick-and-mortar and cross-border stores, are all weighing down its margins. Meanwhile, the growth of AWS' higher-margin business stabilized Amazon's operating margins.

Alibaba's strengths and weaknesses

Alibaba's revenue rose 35% in fiscal 2020, which ended on March 31, and its adjusted EPS grew 38%. It expects its revenue to rise at least 28% in fiscal 2021 -- even after bearing the impact of COVID-19 -- and analysts expect its adjusted earnings to grow 13%.

Those are robust growth rates for a stock that trades at 29 times forward earnings, but Alibaba faces several long-term challenges: It's increasingly dependent on its lower-margin commerce businesses, JD.com and Pinduoduo remain fierce rivals in China's e-commerce market, and Tencent remains a persistent threat in the cloud, digital media, and fintech markets. A new U.S. Senate bill, which hasn't been passed into law yet, could also force Alibaba and other Chinese companies to delist their stocks.

Amazon's strengths and weaknesses

Amazon's revenue and earnings rose 20% and 14%, respectively, in 2019. In the first quarter of 2020, its revenue rose 26% annually, but its earnings tumbled 29% as it incurred roughly $600 million in COVID-19-related expenses. Amazon expects those expenses to rise and exceed $4 billion in the second quarter, which will likely offset its projected sales growth of 18%-20% and result in a net loss.

For the full year, analysts expect Amazon's revenue to rise 24% and for its earnings to tumble 18%. Those are unimpressive growth rates for a stock that trades at nearly 140 times forward earnings. Investors are likely paying a premium for Amazon because they consider its COVID-19 headwinds to be temporary, but they could be overlooking three other significant challenges.

First, Amazon's growing dependence on third-party sellers could cause quality control issues and attract regulators. Second, its e-commerce marketplace faces tough competition from resilient retailers like Walmart and Target, which are matching Amazon's prices and using their brick-and-mortar stores to fulfill online orders. Lastly, Microsoft's Azure, which ranks second in the cloud platform market, is still growing at a faster clip than AWS.

The winner: Alibaba

Alibaba and Amazon are still both sound long-term investments in the e-commerce and cloud markets. However, Alibaba is generating stronger revenue and earnings growth, it operates at higher margins, and its stock looks much cheaper. Therefore, investors can consider accumulating shares of Alibaba right now, but they should think twice before chasing Amazon's stock near its all-time highs.