Investing in retail companies can be a volatile ride. Most retailers rely heavily on the holiday shopping season, and factors like weather and slips in the economy can wreak havoc on a retailer's bottom line. However, at some point, everyone needs to go to a grocery store. But with increasing competition from Internet retailers, is there room for bricks-and-mortar grocery retailers in your portfolio?

Groceries at your doorstep
Kroger (KR 1.80%) is the largest supermarket chain in America. In fact, with nearly $94 billion in annual sales, Kroger is the second largest retailer of any kind, just behind Wal-Mart (WMT 0.46%). With 2,642 supermarkets and over 700 convenience stores nationwide, chances are you've bought something from a Kroger store. With its share price hovering near its all-time high, a P/E of 15.2, and a dividend yield of 1.33%, Kroger appears to be a great addition to any portfolio.

A concern for some has been the threat of large Internet retailers like Amazon.com, who have entered the grocery delivery industry -- a valid concern since Kroger's online sales are currently limited to its King Soopers stores in Denver and 154 Harris Teeter stores in the Southeast. However, just before the long Independence Day weekend, Kroger showed Wall Street that it is serious about strengthening its online presence when it announced plans to buy Vitacost.com for $280 million in cash. Compared to Kroger or Amazon, Vitacost.com is a small company, but it offers some 45,000 products and reported sales of $383 million last year. More importantly, Vitacost provides Kroger with a tested Internet sales model to build on, helping Kroger stay in step with larger, more established online retailers.

Groceries in your neighborhood
You can buy just about anything at Wal-Mart, and that includes groceries. But when all you need is a gallon of milk and some bread, the idea of wandering through a gigantic Wal-Mart store is not appealing. Wal-Mart has addressed this issue by opening several smaller stores under the Wal-Mart Neighborhood Market name. These markets are about a quarter the size of a typical Wal-Mart and offer all of the groceries and personal care items you're likely to find at traditional supermarkets, like those operated by Kroger. At present, Wal-Mart operates just over 400 of these smaller stores.

Wal-Mart has had a strong online presence for years, and consumers have always liked Wal-Mart for its competitive prices. Many customers also know Wal-Mart will match the advertised prices of its competitors. So, where does Wal-Mart go from here? Well, it is launching a digital savings program it calls Savings Catcher, which is rolling out nationally this summer. With Savings Catcher, customers simply scan receipts into their smartphones (or they can enter a code on Wal-Mart's website), and if an independent tracking company finds that a local competitor offers the same items at lower prices, customers automatically receive a refund. The refunded money is loaded onto a gift card that customers can use online or in stores. Savings Catcher should help Wal-Mart attract even more bargain-minded customers, and it will aid the company in capturing data from customers, similar to loyalty card programs offered by other retailers.

Groceries in bulk
Sometimes, the best savings come from buying in bulk. Through its Sam's Club warehouse stores, Wal-Mart has a good foothold in this market, but perhaps arguably, Costco (COST -0.24%) is an even bigger name in the wholesale niche of the industry. Costco operates 464 locations in 43 U.S. states and its customers tend to be very loyal. Since Costco's customers must pay for a membership in order to shop in a Costco store, the company has a built-in data collection system without a loyalty card program. The membership dues add to the company's bottom line, too. Costco tends to operate with small margins in order to offer customers low prices, but it still reported $25.23 billion in net sales for Q3, with a net income of $473 million.

While Costco shows strong sales in its stores, it lacks an online presence, something that makes Amazon a strong threat to Costco. With its Amazon Prime membership option, customers pay an annual fee that entitles them to free two-day shipping on anything Amazon stocks in its warehouses, including groceries.

Bottom line
Like most industries, the Internet and the ubiquity of smartphones have changed the way people buy groceries. While Kroger and Wal-Mart are keeping in step with new technologies, Costco has stuck with its bricks-and-mortar roots. So far, this strategy is working, but as Amazon and other online retailers find new ways to deliver products to customers' doorsteps at even lower prices, traditional grocery retailers will need to reinvent themselves.