Warehouse clubs exist because in exchange for a membership fee they offer low prices, albeit sometimes in inconvenient quantities.

Costco (COST -0.18%) has thrived by serving an audience of members looking for deals. The retailer courts bargain-hunters by cleverly curating its selection of merchandise. The chain always has certain staples such as milk, coffee, and healthcare supplies, while shifting up the rest of its mix.

That makes its stores a bit of a scavenger hunt. You might enter knowing you need K-cups, cereal, or washing machine detergent pods, only to happen upon a great deal for a snowboard. Not every item is actually a deal, but generally the prices are good, and the merchandise mix, heavy use of sampling, and low-cost snack options keep people coming back.

For 10 years that basic formula has produced a near-steady rise in the company's stock price. Until recently there was no reason to believe that might change anytime soon, but there are signs that after an impressive run, Costco stock does face risks from digital competitors, specifically Amazon.com (AMZN -0.18%) and Wal-Mart (WMT -0.63%) which generally have the warehouse club beaten when it comes to price selection. As these rivals improve delivery -- something both have invested heavily in -- Costco may have something to fear.

Over the past 10 years Costco has mostly gone straight up. Image source: YCharts.com.

What should Costco worry about?

Costco offers two things to its customers -- good prices and a shopping experience. Amazon and Wal-Mart, to a lesser extent, already have the warehouse club beaten when it comes to price plus convenience. In most cases, the online sites offer comparable if not better pricing on most items Costco sells without requiring the bulk purchases the warehouse chain forces for many items.

For example, Costco, Wal-Mart, and Amazon all sell generic versions of Prevacid, the popular acid-reflux medicine, with the best deal in all cases being on a three-pack containing six weeks' worth of pills. Amazon and Wal-Mart, however, also offers the option to buy a single 14-pill pack or a 28-dose two-pack -- as well as some larger-than-three-pack offers.

In general, the three-pack is the best price per pill at all three chains (prices can vary), but Amazon and Wal-Mart allow people more choice. That may not matter when it comes to pills, but some Costco customers may not want to buy deodorant six at a time or cereal packaged in two extra-large boxes.

Amazon and Wal-Mart have offered those advantages for years, but they haven't been able to match the immediacy of shopping in a store. That gave Costco (and physical Wal-Marts) a reason for being that digital players could not match.

In recent years, however, Amazon has bridged that gap, with Wal-Mart working hard and spending big to catch up. The online leader now offers Sunday delivery, same-day delivery in some markets, and even nearly immediate service in limited areas. Amazon has also made two-day delivery a standard, with incredible reliability to the point that if a consumer doesn't need something immediately, why not order it from the online giant and not have to leave the house?

Going forward, Amazon -- and eventually Wal-Mart -- could have drone deliveries, trucks with 3-D printers roaming the country, and advanced predictive software that brings items from warehouse to customer even faster. When that happens, Costco, which has mostly ignored its digital operations to keep the focus on its stores, has something to worry about.

Should Costco shareholders worry?

For the Costco customer who visits the store because it's entertaining, faster online shipping and better prices or selection at Amazon.com or Wal-Mart.com shouldn't matter. The shopper perusing the warehouse club based on getting a good deal, however, may eventually be swayed to drop his or her membership.

For now, Costco has an immediacy advantage over its rivals. Going forward that may not be the case, as Amazon and Wal-Mart's digital arm -- which now includes Jet.com -- both shorten the delivery window. That represents a risk for all retailers, but Costco could ultimately feel a pinch it has so far avoided.

As Amazon ups the delivery bar and Wal-Mart scurries along behind it, Costco members may decide that visiting a store -- especially one that charges an annual fee for the privilege -- isn't worth it. When that happens, and the day isn't that far off, Costco memberships, sales, and ultimately share price may suffer.