Amazon (AMZN 0.58%) has rewarded investors over time. The company has increased profit, revenue, and free cash flow over most of the past decade. As a result, the shares climbed more than 1,000% through early this year.

But Amazon's share performance hasn't been as bright this year. The shares have lost 27% so far, underperforming the S&P 500 Index. This isn't catastrophic when you consider Amazon's long-term gains. But it still isn't much fun for those investors who bought Amazon shares more recently. Let's take a look at why Amazon is in the doldrums this year -- and what this means for you.

Two high-growth industries

Amazon operates in two high-growth industries: E-commerce and cloud computing. In fact, it's a leader in both of these areas. Over the past year, various elements have been weighing on the e-commerce business. Higher inflation has increased Amazon's transport and logistics costs, for example. Supply chain difficulties have been another problem.

And, finally, Amazon's own growth added to the challenges. Due to enormous demand during the earlier stages of the pandemic, Amazon expanded its fulfillment network. It actually doubled the size of the network in just two years. As a result, Amazon found itself with excess capacity.

All of these elements together have weighed on earnings. As of the third quarter of last year, operating cash flow and operating income have decreased. By last year's fourth quarter, free cash flow shifted to an outflow of $9.1 billion for the trailing 12 months. And the outflow has continued.

Chart showing Amazon's free cash flow dropping since early 2021.

AMZN Free Cash Flow data by YCharts

Return on invested capital, which has climbed over the years, has also been on the decline.

Chart showing overall rise in Amazon's return on invested capital from 2014 to 2021, with drop after that.

AMZN Return on Invested Capital data by YCharts

At the same time, investors have shied away from stocks that depend on consumer spending. That's because higher inflation is also hurting people's buying power. All of this means Amazon hasn't exactly been at the top of every investor's buy list. And that's why the stock has suffered so far this year.

Why Amazon is a buy today

But the story doesn't end here. Now, let's look at why Amazon actually is a great buy today -- and offers investors a promising future.

As mentioned above, today's economic environment is difficult for the e-commerce business. But it's important to remember that these troubled times are temporary. And Amazon has what it takes to manage them. For example, Amazon said in its most recent earnings report that it's progressing in cutting the costs it can control and improving productivity across its fulfillment network.

Global retail e-commerce is forecast to grow 56% to $8.1 trillion by 2026, according to Statista. Amazon, as a leader, will surely benefit once the economic situation improves.

We haven't yet talked about Amazon's big profit driver. And that's Amazon Web Services (AWS), the global market leader in cloud computing services. AWS is still delivering double-digit growth in revenue and operating income, even during these difficult economic times.

And AWS continues to expand in locations across the world -- and win new contracts. Last year, AWS accounted for more than 70% of Amazon's total operating income. So, the health of AWS is a huge green flag for Amazon.

Amazon also generates revenue through sales of its subscription services and through sales of advertising. Revenue in both of these areas climbed in the double digits in the most recent quarter.

A bargain today

So, what does this mean for investors? If you haven't yet bought shares of Amazon, today, they represent a bargain considering growth prospects. The stock is trading at 2.5 times sales. That's down from more than four late last year.

And if you're already a shareholder, there's no need to worry about Amazon's future. Earnings troubles may not be over in the near term. The shares may not recover overnight. But over time, Amazon's dominance in two enormous businesses should result in earnings growth. And that should translate into share gains -- a great reward for investors who plan to stick with Amazon over the long haul.