More than anyone else, Costco Wholesale (COST -0.11%) and Amazon (AMZN -1.11%) have dominated the current retail era. Costco has regularly put up comparable sales growth in the mid- to high-single-digit range and is the second-largest American retailer by revenue, while Amazon's fast-growing e-commerce business has threatened nearly every corner of traditional retail.

The two companies have managed to grow and take market share when so many other retailers are struggling, largely because of the strength of their membership program and high customer satisfaction. For Costco, that means its warehouse club model, as shoppers must pay an annual membership fee of $60 for the privilege of getting access to its bargain-priced bulk goods, among other benefits. Amazon, meanwhile, has signed up more than 100 million subscribers for its Prime loyalty program, which offers a slew of benefits including free two-day shipping, free video streaming, and discounts at Whole Foods. As it's grown, Prime has become a source of much of Amazon's competitive advantage.

Two hands corral a scale weighing two sets of coins.

Image source: Getty Images.

For both companies, the membership programs lock customers in and incentivize purchasing. Both services have renewal rates of 90% or higher in North America, showing the high levels of customer satisfaction. 

Amazon, of course, is much more than a retailer, as the company has built a leading cloud-computing business among its other ventures; its success as an innovator may explain why the stock has soared over the last five years, easily beating Costco during that time.

COST Chart

COST data by YCharts

Still, with Amazon pushing a $1 trillion market value, investors are unlikely to see a repeat of that performance over the next five years. Which is the better buy today?

A brick-and-mortar success story

At a time when almost every retailer is scrambling to keep up with changes in the industry and fend off Amazon, Costco continues to put up steady growth. Yes, the company has finally begun to embrace e-commerce, offering free two-day shipping for nonperishables with a $75 minimum and same-day shipping on perishables through Instacart, but the company's success comes from the enduring value of its core business model.

Costco offers bargain prices, selling goods nearly at cost, to members willing to pony up the $60 membership fee each year. The retailer is one of the few big-box chains still steadily adding stores, as it opened 13 new warehouses in the U.S. and 21 globally last year. The company's current base continues to grow sales; comparable sales adjusted for fuel prices and currency rose 7% last year and by the same pace for the first half of its current fiscal year. E-commerce sales were also up 26% over the last two quarters. 

It seems, then, that Costco's model is essentially Amazon-proof. Though many of its 52 million members are also Amazon Prime members, consumers see value in belonging to both services. Additionally, Costco's bargain prices make the company relatively recession-proof since shoppers visit its stores to save money, a habit they're likely to keep in a down economy. Like Amazon, Costco also rates high on customer satisfaction surveys, another source of its strength. Considering those attributes and its steady growth, Costco looks like a solid bet to continue outperforming the S&P 500.

The everything company

Amazon's success in e-commerce has become clear -- the company now controls about half of online sales in the U.S. -- but the tech giant is also much more than just an online retailer. Amazon has emerged as the leader, along with Microsoft, in cloud computing; its Amazon Web Services division brought in $25.7 billion in revenue last year, up 47% from a year ago, and operating profits jumped 68% to $7.3 billion.

Meanwhile, the company is taking steps into healthcare with its acquisition of online pharmacy PillPack for $1 billion; the joint venture, called Haven, with JPMorgan Chase and Berkshire Hathaway; and the launch of a new set of healthcare skills on Alexa, its voice-activated technology, allowing users to do things like book doctor appointments and check blood sugar levels.

In e-commerce, Amazon's business is fast evolving as the company increasingly leans on high-margin businesses like its third-party marketplace and fulfillment services to drive growth, moving away from its historical position as a direct seller. That, along with the company's fast-growing advertising business, drove North American e-commerce profits up 156% last year. The company finally seems to be realizing the competitive advantages that its Prime loyalty program and investments in its vast network of warehouses have generated.

With Amazon's revenue reaching $233 billion last year, its top-line growth is likely to slow as the law of large numbers starts to apply; however, profits could just be starting to ramp up.

Which is the better buy?

Comparing the two stocks on a valuation basis, Costco emerges as the clear winner. The warehouse retailer's shares trade at a P/E ratio of 32 compared to Amazon's 93. Costco also offers a dividend, unlike Amazon, currently paying a yield of 1%, and the company has a habit of paying a generous special dividend every couple of years, though management played coy on the recent earnings call about the prospect of offering one again. 

Amazon's higher valuation seems justified when you look at its expected growth, as analysts expect its earnings per share to double over the next couple of years. 

Both of these stocks are appealing buys, but which is the right one for you will probably come down to your investing style. Risk-averse investors will probably prefer Costco, since its more moderate valuation makes it less vulnerable to a sharp pullback. Amazon, on the other hand, has always been a risky stock, but its growth has clearly made up for the pullbacks over its history. Still, Amazon could easily lose 20% or more if market sentiment reverses, much like it did at the end of last year.

If I had to choose between these two companies, I would go with Amazon due to its optionality and vast ambition; the company could disrupt industries like healthcare and supermarkets, which could give the stock more unforeseen growth opportunities. Costco looks like a good bet to continue outperforming the S&P 500, but it doesn't have the same disruptive growth potential as Amazon.