There are two components of successful long-term investing, and both are equally important. First, buy shares of good companies that can grow for many years to come. Second, make sure you pay a reasonable price for those stocks.

That second part often gets thrown away during raging bull markets. Ignoring valuation can sometimes work out fine, but it can also lead to big losses, even if the company does well. Two growth stocks that look too expensive are Amazon (AMZN 0.58%) and Netflix (NFLX 1.73%). Here's why these market-leading companies are questionable investments right now.

Amazon: The market leader's e-commerce has more than dipped since the pandemic peak

E-commerce and cloud computing giant Amazon is worth around $1.3 trillion. Relative to any metric, that's a pricey valuation. Amazon is facing the dual challenges of sluggish consumer demand and a rapidly slowing cloud business.

Profit margins in the e-commerce segment have fallen off a cliff as the pandemic-era bonanza of online shopping has given way to a much more challenging environment. Cost cutting is helping, but e-commerce is still a drag on the bottom line. The North America segment managed an operating margin of just 1.2% in the first quarter, while the international segment suffered an operating margin of negative 4.3%. And remember, these results include high-margin businesses like third-party seller services and advertising.

Amazon Web Services, the company's market-leading cloud computing business, is being rocked by slower growth and soaring costs. AWS revenue rose by just 16% year over year in the first quarter, less than half the growth rate one year ago, and operating income plunged by 21%. Competition has increased over the past few years from fellow mega-platforms like Microsoft Azure as well as from smaller providers like DigitalOcean. And with a significant percentage of cloud spending likely wasted, enterprises have a lot of excess to cut as they look to bring down cloud costs in a tough economy.

All three of the free cash flow measures Amazon reports are in negative territory over the trailing twelve-month period. Analysts are expecting the company to report adjusted earnings per share of just $1.59 this year, which puts the price-to-earnings ratio above 80. While Amazon is still dominant in its core markets, the stock looks far too expensive given the company's challenges.

Netflix: The streaming giant is no longer in growth mode

Netflix has made some major changes recently to boost growth, and they seem to be working. The company rolled out an ad-supported plan late last year and recently cracked down on the practice of password sharing. While revenue and profit grew minimally in the second quarter, which ended June 30, subscriber growth looked better.

Netflix's revenue grew by just 2.7% year over year, and net income rose by just 3.2%. But the company added 1.17 million net subscribers in the U.S. and Canada. Globally, the company tacked on 5.89 million subscribers during the quarter, compared to a loss of 0.97 million subscribers in the prior-year period.

These subscriber gains are a positive development, but the rally in Netflix stock this year makes it tough to get excited about shares of the streaming giant. Even after a post-earnings decline, Netflix remains an expensive stock. The company is valued at about $188 billion, putting the price-to-earnings ratio based on the average analyst estimate for 2023 at about 36.

To be fair, analysts expect significant earnings growth in 2024 as Netflix's initiatives pay off, but the days of consistent double-digit revenue growth appear to be over. While the password-sharing crackdown may drive some subscriber gains in the U.S., there's also a lot more competition today than there was even a few years ago. Netflix is not even close to being the only game in town anymore, and it lacks the established intellectual property that could give companies like Disney an edge.

The fact that Netflix has turned to advertising, something it long shunned, is evidence that the company is now in optimization mode, not growth mode. Netflix stock still has a premium valuation, but with sluggish growth likely to be the new norm, that valuation could come down in the future.