Although artificial intelligence (AI) investing has been a hot-button topic in 2023, investors have lost interest since the market began its decline about a month ago. It's been clear from second-quarter results that AI isn't a short-term catalyst; it's a long-term one. As a result, investors should consider companies with more than one business segment than just AI, as it can help insulate your portfolio from the highs and lows of the market.

One area critical in AI proliferation is cloud computing, as massive data centers give clients access to top-notch computational power without needing to buy the machines themselves. In this space, two of the top providers are Amazon's (AMZN -0.68%)AWS and Alphabet's (GOOG 1.11%) (GOOGL 1.05%) Google Cloud. Read on to find out what makes these two exceptional buys right now.

The cloud computing market opportunity is astronomical

Cloud computing is vital in AI for a couple of reasons. First, AI models require a lot of data to be trained properly. Storing and processing that information can take up a lot of storage space, so many choose to store this information in the cloud. By storing information on the cloud, it isn't just on the internet; it's actually being stored offsite in a data center and accessible through the internet.

Second, developing AI models requires specialized computational hardware that is expensive. Many companies that want to integrate AI into their business wouldn't have use for an extremely powerful computer every day of the year. But, if a cloud computing provider has multiple clients that want access to its resources, the expense is easier to justify.

While this approach has significant AI implications, it also affects other data-driven decisions, such as inventory levels or advertising locations. With an extremely wide use cases for data centers, it's no wonder that the market opportunity for this field is incredible.

One market analysis found that the cloud computing market is worth about $677 billion in 2023, up from $569 billion in 2022. However, it's expected to grow at a 20% compounded annual growth rate to $2.4 trillion by 2030. There are almost no market segments that can increase by four times in size in just seven years, let alone one as massive as cloud computing.

As a result, investors need to have significant exposure to cloud computing in their portfolio, as it will be one of the most significant business trends in this decade. But where do Amazon and Alphabet come into play?

Cloud computing results were mixed in Q2

Amazon Web Services (AWS) and Google Cloud represent this field's largest and third-largest players, respectively. However, each is facing different challenges right now.

In Q2, AWS only grew revenue at a 12% pace, thanks to clients optimizing their spending. This is only a temporary problem, as spending should return once businesses feel more comfortable opening up the checkbook as the economic outlook improves. Until then, the market leader may struggle, as it has a more business-focused client base.

Alphabet's Google Cloud isn't experiencing the same growth woes as AWS, as it increased its revenue by 28% in Q2. However, this business segment is just turning the profitability corner, as it only produced $395 million in profits, good enough for a 5% operating margin. Compared to AWS' 24% operating margin, Google Cloud has a way to go. Still, Google Cloud will likely see more elevated growth levels as it is smaller and is the cloud provider for around 70% of generative AI unicorns (private companies valued at more than $1 billion).

But what makes these two great buys right now is their valuation.

The stocks are trading at reasonable levels

Alphabet and Amazon should be valued in two different manners, as Alphabet is near peak profitability (which is why I will use its price-to-earnings (P/E) ratio), and Amazon is still improving its efficiency (making the price-to-sales (P/S) ratio the best valuation tool).

Alphabet trades for 27 times earnings, which is near its historical average. However, Alphabet is slated to see strong growth over the next year, so its forward P/E is much lower.

GOOGL PE Ratio Chart

GOOGL PE Ratio data by YCharts

As for Amazon, its stock trades for just 2.6 times sales, the same level last seen in 2016. However, this is an incredibly low price for the stock as its gross profit margins have improved (thanks to a revenue mix that includes higher-margin businesses like cloud computing), increasing the business' profitability capability. In return, it should see a high valuation, but that's not what's going on.

AMZN PS Ratio Chart

AMZN PS Ratio data by YCharts

With both businesses having significant cloud computing exposure and trading at attractive valuation levels, each looks like a top stock to buy right now.