There's nothing more fundamental to our survival as human beings than food. Therein lies the appeal in investing in grocery stores: They supply a product that will be in demand year-round, in good and bad economic times, with incredible regularity. While that may not sound like the sexiest business plan to invest in, it has historically provided the type of reliable cash flow prized in retirement accounts. 

But over the past five years, the industry has been turned upside down by changes in business models, a focus on delivery, and mass consolidation. While the dust is far from settled, here are 10 of the largest publicly traded grocers you can buy stock in.

Company Market Cap Stores Regions Chains
Amazon (NASDAQ:AMZN) $780 billion 500 USA Whole Foods
Walmart (NYSE:WMT) $250 billion 11,700 Worldwide Walmart
Costco (NASDAQ:COST) $86 billion 750 USA Costco
Kroger (NYSE:KR) $21 billion 2,800 USA Kroger, Roundy's, Ralph's, Food 4 Less
Sprouts (NASDAQ: SFM) $3 billion 300 Western and Southern U.S. Sprouts Farmer's Market
Weis Market (NYSE: WMK) $1.3 billion 200 Mid-Atlantic U.S. Weis Market
SUPERVALU (NYSE: SVU) $630 million 100 Midwestern U.S. Cub Foods, Shopper's Food, Hornbacher
Ingles Market (NASDAQ: IMKTA) $580 million 200 Southeastern U.S. Ingles Market, Sav-Mor
Smart & Final (NYSE: SFS) $360 million 350 Western U.S. Smart & Final, Cash & Carry
Natural Grocers (NYSE: NGVC) $230 million 150 Western U.S. Natural Grocers

Data source: Yahoo! Finance, company websites.

It's worth noting that there are several important grocers left off this list. Trader Joe's, Publix, and Wegman's are all privately owned. And international players that are moving into the United States like Aldi are also not included.

Publicly traded or not, all of these industry players have to deal with the same set of logistical issues: enormous supply chains spread out over varying geographic footprints. Larger players have the benefit of more leverage when it comes to demanding lower prices from suppliers, while smaller and more regional players are able to enjoy lower costs to maintain their supply chains. 

Despite all of these options, there are only a few players that I would consider long-term, buy-to-hold stocks that will not only still exist 10 years from now but provide market-beating returns.

How can we measure success at grocery stores?

Same-store sales (SSS) and profit margins are the most important metrics for investors to focus on. Any company can expand sales by opening up new locations, but only the truly excellent will be able to consistently increase sales at existing locations (same-store sales) while maintaining profitability (profit margins) year after year.

To get an idea of how hard this can be, let's take a look at Kroger, the largest "pure-play" grocer in America.

Chart showing profit margins and same store sales at Kroger between 2013 and 2017

Data source: Company annual reports. SSS is reported as "identical supermarket sales excluding gas" by Kroger.

As you can see, things progressed very nicely from 2013 to the end of 2015, with SSS expanding beyond the pace of inflation and profit margins growing larger by 32 basis points. That helps explain why shares returned 250% for shareholders between January 2013 and December 2015.

After that, however, things went south: Profit margins contracted back to their 2013 levels, and sales at existing locations were barely above the breakeven point. Not surprisingly, shares have lost 40% of their value since the trend started in early 2016.

Why are so many grocery stores being acquired?

Coming out of the Great Recession of 2008, there were several major grocers whose stock you could buy on the open market. As soon as the worst of the recession had passed, however, consolidation started in earnest.

But all of this preceded the acquisition that was marked as a game changer: Amazon's $14 billion acquisition of organic foods purveyor Whole Foods.

To understand why this acquisition is so important, it's crucial to understand what separates one grocery store from another. In the business world, companies try to build moats -- or sustainable competitive advantages -- around themselves to protect their businesses. 

Facebook, for instance, benefits from the network effect: Each additional user makes the service even more powerful and makes it harder for the competition to build a competing platform. And Intuit's TurboTax benefits from high switching-costs -- we don't have to worry about inputting the wrong data on our tax forms when TurboTax has stored decades worth of information that it can fill in automatically.

Supermarket aisle with empty green shopping cart

Image source: Getty Images.

But in the grocery world, the moats are very narrow. Stores historically have focused on the value of their brand in regional areas of the country. By focusing on just one region, grocery stores could also hold down distribution costs and pass those savings on to customers. But at the end of the day, margins have always been razor thin: a grocery store is lucky if it can keep just two cents of every dollar spent in-store.

Will there be any traditional grocers in the future?

Why did fortunes swing so quickly against Kroger starting in 2015? It's a story playing out across the industry, and it all comes down to competition. Specifically, three different approaches are taking hold that are significantly undercutting the moats of traditional grocers.

The first is buying food in bulk. This is hardly a new concept and was pioneered by Costco's membership model. What many people might not realize about Costco is that the company actually sells all of its goods -- both food and nonfood -- at a loss. Every penny of profit actually comes from membership dues. Last year, for instance, Costco brought in $2.7 billion in net profit. Of that, $2.9 billion came from membership fees. In other words, without the memberships, Costco would be a money-losing venture.

It's very difficult for traditional grocers to compete with those prices. Without a membership model that charges upwards of $50 per year, these industry players are forced to slash their own prices without the benefit of additional income from other sources.

A second approach has been pioneered by Walmart: offering food at ever-thinner margins to get people in the store and buying higher-priced goods. Back in 1997, grocery items accounted for just 14% of the company's overall sales, or $17 billion total. After experimenting with grocery-only stores, executives realized that by combining the traditional Walmart nonfood offerings with an expanded grocery section, it could offer food for lower prices than traditional grocers and count on customers buying slightly higher-margin nonfood items while making their weekly grocery run. 

The approach has paid off handsomely: Food sales accounted for 56% of all sales during the last fiscal year, or roughly $280 billion. In other words, sales of groceries increased at a 15% clip -- per year -- for over two decades at Walmart.

But the final approach to undercutting traditional grocers pioneered by Amazon is the one getting all of the attention right now. No company has captured a larger swath of the e-commerce pie than Amazon. Until its acquisition of Whole Foods, though, its moves into the food business were modest at best.

With the acquisition of Whole Foods, Amazon has the opportunity to combine the best of both Walmart and Costco's approaches, while adding an e-commerce twist. Amazon Prime costs roughly twice as much as a Costco membership but is a huge money saver for consumers around the world. And it's also wildly popular, with CEO Jeff Bezos recently revealing over 100 million households have memberships. 

We already know that Prime members spend almost twice as much on primarily nonfood goods on the company's platform. By offering special discounts to in-store shoppers at Whole Foods, it could woo even more health-conscious consumers into its ecosystem. We don't yet have any hard figures provided by Amazon as to how much grocery sales -- whether through Whole Foods' brick-and-mortar locations or online -- contribute to top-line growth. All of the results are simply consolidated. 

Before being acquired, Whole Foods registered sales of $16 billion for fiscal 2017. To put that in perspective, in 2016, Americans spent over $800 billion on food. Right now, Amazon's Whole Foods is just a sliver (less than 2%) of that pie.  

But why even focus on in-store when trends are decidedly moving toward online ordering of groceries and delivery. Amazon has an unmatched infrastructure via its enormous network of multimillion-dollar fulfillment centers throughout North America to get those groceries to your house faster and cheaper than the competition. And while its grocery segment is minuscule right now compared to Walmart or Kroger, Amazon has shown time and again that it can quickly disrupt industries and grab market share by leveraging this network.

To its credit, Walmart is moving fast -- and doing impressively well -- at offering its own delivery services. The acquisition of Jet.com in 2016 markedly improved Walmart's e-commerce game, both for groceries and nonfood items. But at the end of the day, Walmart still has to compete against an Amazon company with an enormous e-commerce lead, a better logistics and fulfillment network, and management that's willing to offer even deeper discounts to low-income customers to get them in the Amazon ecosystem.

The best bets if you want to invest in grocery stocks

As you can see, the deck is decidedly stacked against traditional grocers that count on food sales alone for the bulk of their income. Without any type of membership program, these industry players will be fighting an uphill battle to remain the food provider of choice in their communities. 

Costco

Costco should be able to survive thanks to its stellar reputation, ultra-low prices, and membership model. Recently, the company announced that same-store sales increased a whopping 10.2% -- a very positive sign that the concept is popular with members. But that's not the best metric to evaluate the company's stock. Costco offers its goods for such razor-thin margins that -- last year -- membership dues ($2.85 billion) outstripped net income ($2.68 billion).

In other words, Costco sells everything at a slight loss and makes all of its profit off membership dues. Therefore, growth in membership dues -- through a combination of attracting new members and raising annual prices -- is a better indicator of the company's momentum than sales. 

That's why I remain pessimistic on the company's stock -- at least over the medium term -- thanks to a hefty price tag of 30 times free cash flow. I simply don't think that membership income will grow at a pace to justify that price tag.

Should that come down below 25, I would consider it a fair buy.

Walmart

Walmart should be able to remain relevant and a regular provider of groceries moving forward as well. The company has surprised me with its ability to jump-start its e-commerce operations after years of floundering. The most important recent move was the acquisition of Jet.com -- which has far exceeded expectations. While I don't own the stock personally, I have given it an outperform rating on my own CAPS profile

Amazon

If I had to choose one grocery stock as the biggest winner, it would definitely be Amazon. The company's overarching mission is to be the earth's most customer-centric company. Since starting out as an online book-seller, Amazon has disrupted countless industries with this mission. Whether it's offering new ways to consume media (e-readers) or offering a plethora of benefits for very low prices (Amazon Prime), the company has sought to simply make customers happy.

Beyond Whole Foods, the company has a number of test-balloons in the industry. Amazon Go -- an AI-infused shopping experience -- was recently rolled out to the public on a limited basis. Amazon Fresh -- the company's online grocery-delivery service -- has been growing very quickly and is estimated to have monthly sales of over $7 million. While the great majority of grocery sales still take place in brick-and-mortar locations, Amazon was estimated to have an 18% market share of online sales at the beginning of the year. Clearly, all the pieces are in place for Amazon to leverage its leading e-commerce position in the industry.

In the interests of full disclosure, I'm certainly biased in this opinion: Amazon accounts for over 20% of my real-life holdings. That wasn't, however, by design: The stock has simply continued to grow since my initial purchase in 2010, to the point where it has become a major force in my portfolio. But when it comes to groceries, I think a powerful trio of factors will make it the king of the industry: an unmatched logistics and fulfillment network to guarantee quick delivery, a membership program that keeps customers locked in, and other more profitable business segments that will allow it to offer food for the same price or less than the competition.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Brian Stoffel owns shares of Amazon and Facebook. The Motley Fool owns shares of and recommends Amazon, Facebook, and Intuit. The Motley Fool recommends Costco Wholesale. The Motley Fool has a disclosure policy.