Costco Wholesale (COST -0.02%) is often seen by retail investors as a top-tier option. Costco has been performing well for many years, and its target demographic has been feeling healthy in a financial sense in recent years. However, there might be one overwhelming challenge ahead.

Costco vs. Sam's Club
Wal-Mart Stores
' (WMT 0.40%) Sam's Club is a competitor to Costco, which given the significant differences in cash flow generation would appear to put Costco at a distinct disadvantage:

COST Free Cash Flow (Annual) Chart

COST Free Cash Flow (Annual) data by YCharts

However, this picture can be misleading. Wal-Mart is highly diversified with many different channels (supercenters, small-box stores, Sam's Club, e-commerce, and international operations.) This means that the cash flow isn't solely focused on Sam's Club.

Additionally, Sam's Club targets a lower-income consumer. Many Sam's Club warehouses are located in low-income and middle-income areas, whereas Costco warehouses are located in middle-high to high-income areas.

Logically, Costco's annual membership fees are higher. These differences are important because the low-income consumer is struggling due to a reduction in government benefits and a lack of wage growth. With these headwinds, consumers aren't eager to pay upfront membership fees. Costco's target customer is willing and able to do so, however, especially given the future savings on purchases. 

To give you an idea on the differences between Costco and Sam's Club, consider each company's average revenue per warehouse. In 2013, Sam's Club averaged $80 million in revenue per warehouse, less than half the $162 million that Costco averaged in revenue per warehouse.  While Sam's Club suffered a 1.4% decline in operating income in Wal-Mart's first quarter, Costco delivered a 5.6% profit increase to $561 million in its third quarter.

Sam's Club is not a serious threat to Costco. There's another retailer that has much more potential to do long-term damage, though.

Costco vs. Amazon
Amazon.com (AMZN -1.65%) isn't often thought of as a competitor to Costco, but here's a simple rule to follow with retail investing: Amazon is a threat to every retailer.

During Costco's Q&A session on the company's most recent conference call, Chief Financial Officer Richard Galanti was asked how the company competes when Amazon is so aggressive with much of what Costco carries.

Galanti pointed to quality, merchandise mix, and value. He also stated that gasoline brings a lot of people to the parking lot. Good points, but Amazon has been much more in tune with today's younger consumer, especially Millennials. At the moment, the majority of Costco's members are Baby Boomers. This ties into having warehouse locations in higher-income areas, where people own homes and also have more discretionary income than the average consumer. That's good news for now, but is potentially bad news for later. 

In order to attract more Millennials (we're skipping the often-overlooked Generation X demographic due to its smaller size), Costco is increasing its offerings of organic produce and fresh meat. These items have higher price points, but it will take time to grow. (Millennials are very health-conscious.) 

The problem is that Millennials are saddled with high student debts and therefore aren't as interested in home ownership as previous generations. Many of these consumers want to rent and live in urban areas that don't require the ownership of a car. In order to cater to this trend, Costco is attempting to increase its e-commerce presence by adding mobile apps, adding online merchandise (such as limited apparel and limited health and beauty), and by selling memberships on social media sites such as Living Social and Zulily.

Furthermore, Costco is testing Google Shopping Express in Los Angeles, San Francisco, Colver City, and Manhattan. This service allows members to order products online and have those products delivered on the same day. 

If Costco manages to acquire younger consumers, it would be a positive, especially since there's a low cost of acquisition. However, these consumers don't spend as much as Baby Boomers or Generation X'ers.

As far as Costco not losing sales to Amazon, when Galanti was asked about this, he stated that Costco would have to figure out how not to lose as much in sales as other competitors and to drive sales in other ways; that's not very comforting. So far, Costco has been good at thwarting the Amazon threat, but this might not be true when Baby Boomers age.  

The bottom line
For now, as well as for the next several years, Costco should continue to dominate the membership warehouse scene. This should allow for a quality investment opportunity. Looking way down the road, though, Costco might have a dilemma when its primary customer base ages and spends less. A lot will depend on Costco's ability to intrigue Millennials and effectively innovate in the e-commerce space.