This has been a massive year for the S&P 500 index. It's sitting on a gain of 26% (including dividends), which reverses all of its losses from 2022.

Historical data going back to 1957 says rebound years like 2023 have always been followed by second positive year. That bodes very well for 2024 -- we could be looking at a gain of 15.5% in the S&P 500 in 2024, based on the average return of the last 11 times a down year in the market was followed by a rebound year.

But I think two stocks could deliver an even higher return in 2024. Oracle (ORCL 2.02%) and DigitalOcean (DOCN 3.30%) each have a strong presence in cloud computing, and they are rapidly growing their portfolios of artificial intelligence (AI) products. Here's why they have all the right qualities to beat the market.

Two people looking at a tablet computer in front of stacks of supercomputers.

Image source: Getty Images.

1. Oracle is facing astronomical demand for its AI cloud infrastructure

Oracle was founded in 1977 and it has a stellar track record of success, which makes it a great investment in any given year. The launch of Oracle Cloud Infrastructure (OCI) in 2016 laid the foundation for the company's growing presence in the artificial intelligence space.

OCI is a broad platform that allows businesses to build and operate different applications at scale. When digital workloads require a significant amount of computing power, OCI's centralized data centers are a great choice because they are fitted with the latest computer chips. AI happens to be one of the most compute-hungry technologies in history, and it's the reason Nvidia's graphics processors (GPUs) have been in such high demand this year.

AI models are used for a growing number of tasks. Consumer-facing generative AI applications like ChatGPT can create text, images, videos, and computer code on demand. Businesses, on the other hand, run AI in the background to analyze high volumes of data. Research shows increasing scale is the surest way to make AI models more accurate; more data and more training leads to better outcomes. Hence, the demand for computing power is soaring.

In fact, in Oracle's recent fiscal 2024 second quarter (ended Nov. 30), Chairman Larry Ellison said the company was expanding 66 of its existing data centers and building 100 more. He told investors the demand for OCI and generative AI services is increasing at an "astronomical rate," and Oracle simply can't keep up. Building new infrastructure takes time, but Nvidia is also facing so much demand that there is a shortage of its GPUs, which Oracle needs.

During Q2, the OCI segment generated $1.6 billion in revenue. While that only accounted for 12% of Oracle's total $12.9 billion in sales for the quarter, it was a 52% year-over-year increase, making it the fastest-growing part of the company. Ellison says OCI will likely grow at 50% for years to come, so it won't be long before it's a significant part of the revenue base.

Ellison says OCI's new Gen2 Cloud is now the No. 1 choice among generative AI developers, and it attracted top start-ups like Cohere and Elon Musk's xAI. They have already committed to spending billions of dollars on Gen2 Cloud computing capacity, but not even Musk can get his hands on enough.

But 2024 could be a breakout year for Oracle as more of its new data centers come on line. Plus, given its stock sports a price-to-earnings (P/E) ratio of just 29 right now, it would have to rise 23% just to trade in line with the 36 P/E of Microsoft, another leader in AI cloud services. That alone would be enough to beat the S&P 500 next year.

2. DigitalOcean acquired a great AI partner

DigitalOcean is a minnow in the cloud computing industry. The company is worth just $3.1 billion, while its competitors -- Microsoft Azure, Amazon Web Services, and Alphabet's Google Cloud -- are backed by their trillion-dollar parent companies.

In order to thrive in that environment, DigitalOcean delivers cloud services primarily to small and midsize businesses -- typically those in the start-up phase to those with 500 employees. Revenue per customer is relatively low at this end of the market, so it isn't a focus area for the large providers.

The strategy works for DigitalOcean because it delivers a narrow range of cloud services, so it doesn't have the bloated cost structure of its bigger competitors. It offers customers transparent pricing, personalized service, and educational material to help them extract the most from their cloud experience. But in July, DigitalOcean acquired AI cloud platform provider Paperspace, which is on a mission to make high-performance computing available to the smallest of enterprises -- so the two companies appear to be a great fit.

DigitalOcean already offers customers the basics like data storage, server hosting, and the infrastructure with which to build software applications. But Paperspace brings data centers fitted with the latest GPUs, which are required to develop, train, and deploy AI models. It offers customers pricing that is up to 70% cheaper than Microsoft Azure, making it the perfect provider for start-ups.

DigitalOcean values its addressable market at $98 billion, but the addition of AI services could launch the company into an opportunity worth 100 times more over the long term. Depending which Wall Street forecast you rely upon, generative AI could add anywhere between $7 trillion and $200 trillion to the global economy in the coming decade.

DigitalOcean stock is trading 71% below its all-time high following the brutal pullback in tech valuations in 2022. Based on the company's $675 million in trailing 12-month revenue, its shares trade at a price-to-sales ratio of just 4.6.

That's near the cheapest level since DigitalOcean came public in 2021, so investors might want to scoop up the stock before the Paperspace integration starts to bear fruit.