It's easy to invest in the stock market when it's consistently moving higher, and for the most part, that's been the case since the pandemic market bottom in March 2020. But the market has been especially volatile since November 2021, particularly in the technology sector.

Many individual tech stocks have collapsed by 50% or more, plunging them deep into bear-market territory. But there's a handful of high-quality names that consistently outperform and two that are especially worth buying when uncertainty takes hold.

An IT professional analyzing a laptop plugged into a server.

Image source: Getty Images.

Both Microsoft (MSFT -0.66%) and Amazon (AMZN -1.11%) have an impeccable track record of outperforming the broader stock market, having risen 295,000% and 164,000% respectively since their initial public offering (IPO) dates. For context, the widely followed S&P 500 index has returned 3,700% over the last 40 years. 

1. The case for Microsoft

In a difficult market, owning diversified companies can help to protect against excessive downside. Microsoft operates a portfolio of globally recognized businesses that perform well in different environments, so when one is struggling due to external factors like economic uncertainty, others often pick up the slack. 

Microsoft's software products, like Windows and Office 365, serve billions of users around the world. The company is also running a booming hardware segment that includes the Surface line of tablets and notebooks, plus its Xbox gaming brand. Microsoft's gaming business is especially interesting because the company recently acquired developer Activision Blizzard, which is best known for its Call of Duty series. On the business diversity front, this acquisition adds yet another arrow to Microsoft's quiver. 

But the company's largest segment by revenue is actually cloud services, driven by its Azure platform. Broadly speaking, cloud computing allows businesses to access applications and conduct their operations online rather than having critical programs installed on local devices. Microsoft Azure offers over 200 products and 40 solutions, including a platform to build advanced technologies like artificial intelligence and machine learning. Azure is used by 95% of the Fortune 500 companies. 

Combined, Microsoft's segments are delivering steady and reliable revenue and earnings growth even in difficult times.

Metric

Fiscal 2020

Fiscal 2022 (Estimate)

CAGR

Revenue

$143 billion

$196 billion

17%

Earnings per share

$5.76

$9.22

26%

Data source: Microsoft, Yahoo! Finance. CAGR = Compound Annual Growth Rate.

Microsoft's stock trades at a forward price-to-earnings (P/E) multiple of 32, which is a premium to the technology-centric Nasdaq 100 indexes' forward multiple of 22. It suggests investors believe Microsoft is a better place for their money than the broader tech market, which is a useful indicator in times of volatility.

Two people standing in a data center with a laptop, analyzing a digital screen.

Image source: Getty Images.

2. The case for Amazon

Like Microsoft, Amazon is a company many consumers are familiar with. The e-commerce giant has over 200 million members subscribed to its Prime service, and estimates suggest it accounts for about half of all online sales in America. It's rather mind-boggling to think one company could manage so much market share, so it's certainly worthy of its current $1.4 trillion market valuation. 

Amazon also has a diverse business. Its cloud services brand, Amazon Web Services (AWS), currently holds top spot in the industry, trailed by Microsoft Azure, which comes in at No. 2. It also has a streaming service called Prime Video, which is available to all of the company's Prime members. In addition to hit shows and movies, it has snatched up valuable sports real estate, including exclusive UEFA Champions League soccer tournament matches and the NFL's popular Thursday Night Football.

But in terms of financial performance, Amazon Web Services does most of the heavy lifting. It accounts for about 13% of total revenue but generates the majority of the company's profit. While the rest of Amazon's businesses made operating income of $8.1 billion in the first nine months of 2021, AWS delivered an operating income of $13.2 billion. AWS also grows revenue at a much faster rate than the company as a whole.

But overall, Amazon's segments band together to generate a stunning amount of growth for a company of its size.

Metric

2019

2022 (Estimate)

CAGR

Revenue

$280 billion

$553 billion

25%

Earnings per share

$23.01

$51.01

30%

Data source: Amazon, Yahoo! Finance. CAGR = Compound Annual Growth Rate.

Similarly to Microsoft, Amazon's stock trades at a premium to the Nasdaq 100's forward price-to-earnings multiple of 22. Right now, Amazon's forward multiple is 55, signaling strong confidence about the company's future prospects.

To place a fine point on it, shares of Microsoft and Amazon are a great place to ride out the present bout of stock market turmoil, and they're also fantastic long-term additions to any portfolio.