E-commerce and cloud leader Amazon.com (NASDAQ:AMZN) reported its third-quarter results on Thursday, Oct. 24. While the initial after-hours reaction was a severe 7% sell-off, Amazon's stock did bounce back the next day to just a 1.1% decline. Still, this was well behind the overall market, which had a largely positive day.

Why all the pessimism? Aside from the company's perhaps less-than-stellar guidance for the fourth quarter, Amazon's spending has gone through the roof, sending earnings per share down 26% from the prior-year quarter to $4.23, and missing analysts' estimates by $0.32 -- despite the company's impressive 23.7% top-line growth. The spending spree is kicking in big time for both Amazon's core e-commerce business, where the company continues to invest heavily in one-day shipping, as well as for Amazon Web Services (AWS), where margins compressed heavily year over year.

My interpretation is that AWS' slight revenue deceleration and big margin compression were the main culprits for the sell-off. But if investors step back and look at how Amazon is investing in AWS, you'll see a company that's playing the long game, and playing it brilliantly -- in fact, much better than competitors.

Closeup of poker chips on a felt table as a gambler shoves all-in.

Image source: Getty Images.

A big investment

In the quarter, AWS saw its revenue grow 35%, a healthy rate but a slight deceleration from last quarter's 37% year-over-year growth and the first quarter's 42%. While it may alarm some to see competitor Microsoft's (NASDAQ:MSFT) 59% Azure growth and Alphabet's (NASDAQ:GOOGL) (NASDAQ:GOOGL) higher cloud growth as well (though it doesn't release exact numbers for Cloud), remember that AWS is much, much bigger than both Azure and Google Cloud combined. According to Gartner, Amazon had nearly 48% market share of the infrastructure-as-a-service market last year, while Microsoft and Google combined for less than 20%.

It's much easier to grow faster when you're much smaller, so investors shouldn't exactly complain about 35% growth off that big of a base.

Margin compression shows investment in the future

In addition to the AWS deceleration, investors may have also been spooked by a big margin decline for AWS, which saw its operating margin fall from an all-time high of 31.1% in the year-ago quarter to just 25.1% in the recent quarter.

Addressing AWS revenue and margins, CFO Brian Olsavsky said on the conference call with analysts:

... we continue to invest in AWS. If you look at the progression of our operating margin in that business, it reached a high of 31% last Q4, excuse me, Q3. That was a time when we were -- as we mentioned at the time, it was very efficient. We had been banking some savings from forward investments in infrastructure in 2017... We continue to feel really good about not only the top line, but also the bottom line in that business, but we are investing a lot more this year in sales force and marketing personnel, mainly to handle a wider group of customers, an increasingly wide group of products.

We continue to add thousands of new products and features a year, and we continue to expand geographically. So the biggest impact that we saw in Q3 year over year in the AWS segment was tied to costs related to sales and marketing year over year and also, to a secondary extent, infrastructure, which if you look at our capital leases or equipment leases line, it grew 30% on trailing-12-month basis in Q3 of this year, and that was 9% last year.

There you have it: Last year, Amazon had stepped off the gas in terms of investing in AWS, and investors saw the margin potential of the business. But that's when Amazon's competitors Microsoft and Google went on the offensive, greatly increasing their spending on data centers and infrastructure in a bid to catch up. Microsoft's capital expenditures surged 43% and 19.7% each of the past two years, and Alphabet's capital expenditures nearly doubled in 2018 alone.

Playing the memory cycle perfectly

Last year, when Microsoft and Google were heavily investing, it also happened to be a time when the costs for tech infrastructure, such as semiconductors and memory chips, were soaring. Memory costs per gigabyte usually decline over time, but some years show bigger declines than others, and sometimes memory prices even increase. The 2017-2018 period was one of those times. NAND flash prices barely moved, and DRAM prices actually surged at a near-unprecedented rate.

But 2019 is a much different story. Due to the trade war and rising interest rates, growth has slowed, and the costs for various types of memory such as DRAM and NAND flash have plummeted.

Consider these data points from leading memory producer Micron Technology (NASDAQ:MU), which disclosed its annual growth in average selling price (ASP) for memory in its recent annual report, for the year ended Aug. 29:

Change (Decline) in ASP

DRAM

NAND

2019 from 2018

(30%)

(44%)

2018 from 2017

37%

(8%)

2017 from 2016

19%

(7%)

2016 from 2015

(35%)

(19%)

2015 from 2014

(11%)

(15%)

Data source: Micron 2019 annual report. 

Looking at the above table, when would you have rather bought huge amounts of DRAM and/or NAND flash memory? In 2019, or 2017 and 2018?

It's pretty clear that Microsoft and Google were investing a lot when memory prices were going up (and may themselves have spurred some of that price increase). On the other hand, these were times when Amazon was actually lightening up its investments. Now that memory prices have crashed, Amazon is once again stepping on the gas, taking advantage of the memory down cycle, which is showing signs of hitting bottom.

Amazon could win a price war

Although some customers, like major retailers, might refuse to use AWS on the basis of competition, it's highly likely that Amazon could win lots of cloud business on the basis of cost alone. It still has the largest scale and, judging from its savvy buying patterns, likely has the lowest cost per bit as well. In fact, the company noted in its release that it dropped the price of its Infrequent Access Storage class by a whopping 44% in the quarter. That class is for storage that doesn't need to be immediately accessed for 30 days, and takes up a lot of volume. That's a huge price cut, and may have also affected the "mere" 35% revenue growth for AWS last quarter. In fact, Amazon has reduced AWS prices at six different times in 2019, and 75 times since the service began.

Clearly, CEO Jeff Bezos doesn't manage the business on a per-quarter basis, but rather with a multiyear time horizon. As shown in Amazon's opportunistic investment surge, the company isn't afraid to make current numbers look ugly to achieve a beautiful long-term result. In the coming years, I'd expect 2019's heavy investments to pay off quite nicely for AWS and Amazon investors. That's why it remains a top stock to anchor any portfolio, even after its recent sell-off.