Image source: The Motley Fool.

Costco (COST -0.11%) last October boasted that it had recently become the second largest retailer in the world, behind only Wal-Mart (WMT -0.32%). What's amazing about that statistic is that the warehouse giant handles its huge sales volume at a fraction of Wal-Mart's footprint. Costco produced $110 billion of revenue last year through just 686 locations. Wal-Mart required 11,500 stores (17 times Costco's base) to produce less than five times that sales output.

Yet the retailer is now being overtaken by Amazon.com (AMZN -1.11%), a company that has essentially zero physical store presence.

COST Revenue (TTM) Chart

COST Revenue (TTM) data by YCharts.

We're No. 2!

The above chart shows that, in fact, Amazon has already passed Costco in trailing-12-month revenue. The e-commerce giant crested $120 billion in late June thanks to a 29% spike in revenue over the last six months. Costco's growth, meanwhile, has been much slower – up 2% over the last 12 months.

A big factor behind that disappointing figure has been the drop in fuel prices relative to the prior year. Still, the warehouse giant clearly can't grow at anything close to the double-digit pace that Amazon routinely enjoys.

It's premature for CEO Jeff Bezos and his team to pop the champagne and claim second place since a large part of its growth isn't tied to retailing. Take out its services division, which includes the booming AWS cloud business, and you're left with a significantly smaller footprint. All told, Amazon has sold about $90 billion of actual stuff over the past four quarters, and so Costco still has the online giant beat in that key metric -- at least for now.

Gaining ground on profits

Amazon appears poised to pass Costco in terms of total profits for the first time. Since its earnings are generated from steady, predictable subscriber fees, though, Costco's net income chart doesn't include the wild swings or periods of loss that Amazon investors have had to endure lately:

COST Net Income (TTM) Chart

COST Net Income (TTM) data by YCharts.

Bezos and his team don't prioritize earnings, choosing instead to focus on cash flow. Thus, investors can't assume that another ramp up of spending on hardware or infrastructure initiatives won't send Amazon's reported profits lower again. Costco's earnings growth, in contrast, is likely to speed up since its customers are due for their first membership fee boost in years.

Yet investors are much more eager to own a piece of Amazon's earnings right now. Costco can be bought for about 28 times its $2.4 billion of profit while you'll have to shell out nearly 200 times Amazon's trailing earnings for its stock.

Profit-margin challenge

The third major metric that Costco is about to cede to Amazon is profit margin. The warehouse giant has kept its bottom-line profitability steady at about 2% of sales over the last decade. Amazon's dipped below that mark in early 2012 but is making a solid rebound right now.

AMZN Profit Margin (TTM) Chart

AMZN Profit Margin (TTM) data by YCharts.

It's unclear where that number will land for the full 2016 fiscal year thanks to the wide range that Bezos and his executive team has laid out for investors. The third quarter should generate as little as $50 million or as much as $650 million of operating profits, they forecast, which would correspond to either a 60% boost -- or a 90% slump -- against the prior year.

Judging by their stock prices, investors are willing to look past that huge volatility and instead zero in on the projected 27% sales spike that should push revenue to $33 billion. Costco's sales should rise by 3%, according to consensus estimates. The warehouse giant will still edge Amazon by producing about $37 billion of revenue in the third quarter, analysts say. It won't be long before Costco consistently puts up smaller numbers than its online rival, though.