The S&P 500 and Nasdaq Composite indexes have declined about 8% and 14%, respectively, so far this year. Concerns about soaring tariffs, sticky inflation, and elevated interest rates have driven many investors away from stocks and toward more predictable income investments.

But over the past 20 years, the S&P 500 and Nasdaq have still risen 360% and 734%, respectively, even as the global economy was rattled by recessions, geopolitical conflicts, trade wars, and a worldwide pandemic. Therefore, investors who tuned out the near-term noise and simply held their stocks for the long term got a lot richer.

A happy investor points to a rising stock chart.

Image source: Getty Images.

So instead of fretting over the near-term chaos from higher tariffs, let's take a deep breath and review two long-term winners: Amazon (AMZN -1.30%) and Costco Wholesale (COST -0.23%). Both of these resilient stocks beat the S&P 500 and Nasdaq over the past two decades, and they might maintain that market-beating momentum for the next 20 years.

Amazon

Amazon's stock has soared 10,410% over the past 20 years. From 2004 to 2024, its revenue grew at a compound annual growth rate (CAGR) of 25% as its net income increased at a CAGR of 26%. That growth was driven by the rapid expansion of its e-commerce marketplace and Amazon Web Services (AWS) cloud platform.

Today's Change
(-1.30%) -$2.36
Current Price
$179.76
Arrow-Thin-Down
AMZN

Key Data Points

Market Cap
$1.9T
Day's Range
$177.94 - $182.35
52wk Range
$151.61 - $242.52
Volume
35,889,547
Avg Vol
47,780,315
Gross Margin
48.85%
Dividend Yield
N/A

Today, Amazon is the world's largest e-commerce and cloud infrastructure company. Its online marketplace serves over 315 million customers worldwide, and more than 200 million of those customers are locked into its Prime subscriptions -- which provide free shipping, discounts, digital streaming services, and other perks. AWS controlled 33% of the global cloud infrastructure market at the end of 2024, according to Canalys.

Amazon usually subsidizes the expansion of its lower-margin retail business with its higher-margin cloud business. That unique business model gives it an edge against other retailers, and it could partly offset the impact of Trump's higher tariffs on its retail business. Amazon's cloud platform has also been rolling out more tools and services to support generative AI applications.

From 2024 to 2027, analysts expect Amazon's revenue and earnings per share (EPS) to grow at a CAGR of 10% and 20%, respectively. It still looks reasonably valued at 26 times next year's earnings, so its recent tariff-induced swoon looks like a good buying opportunity.

Costco Wholesale

Costco's stock has rallied 2,110% over the past 20 years. From fiscal 2004 to fiscal 2024 (which ended last September), the warehouse retailer's revenue rose at a CAGR of 9% as its net income increased at a CAGR of 11%.

NASDAQ: COST

Costco Wholesale
Today's Change
(-0.23%) -$2.26
Current Price
$977.06
Arrow-Thin-Down
COST

Key Data Points

Market Cap
$435B
Day's Range
$974.62 - $993.87
52wk Range
$702.00 - $1,078.23
Volume
1,272,925
Avg Vol
2,418,309
Gross Margin
12.67%
Dividend Yield
0.47%

Costco's steady growth was driven by its store openings, new memberships, and high renewal rates. From fiscal 2004 to fiscal 2024, its number of warehouses more than doubled from 442 to 891 locations, its number of cardholders more than tripled from 42.4 million to 136.8 million, and its global renewal rate rose from 86% to 90.5%.

As a warehouse retailer, Costco attracts its customers with bulk discounts. It also increases the stickiness of its memberships with additional discounts for fuel sales, optical services, insurance plans, and vacation packages. It can afford to sell its products at low margins because it generates most of its operating profits from its membership fees.

Costco will inevitably be affected by rising tariffs, but higher costs will likely also drive cost-conscious shoppers to make more bulk purchases. So as long as Costco keeps opening new stores, gaining more cardholders, and maintaining high renewal rates, its profits should keep climbing. From fiscal 2024 to fiscal 2027, analysts expect Costco's revenue and EPS to grow at a CAGR of 7% and 10%, respectively. Its stock might seem a bit pricey at 48 times next year's earnings, but it could head even higher over the next two decades as more investors recognize the resilience of its evergreen business model.