The stock market has been booming in 2024. Through the end of July, the S&P 500 index was up more than 15%, a stellar performance driven partly by artificial intelligence (AI) mania.

It's becoming less clear that the good times will last through the end of the year. Popular AI stocks have taken big hits; a weak U.S. jobs report has fueled concerns about a potential recession; and volatility may be on the rise. The major U.S. stock indices plunged last Monday, the largest one-day drop in about two years.

It's impossible to predict what the market will do in the months ahead, but long-term investors should be ready to scoop up bargains if panic takes hold. Here's why I've got Arista Networks (ANET -1.59%) and Cloudflare (NET -1.78%) on my market sell-off watchlist.

Networking for the AI era

Data centers designed for training and running advanced AI models have different requirements from those tuned for general cloud workloads. A mass of AI accelerators, often graphics processing units (GPUs) from Nvidia, need to be linked together, and communication must be fast to take full advantage of that hardware. Network congestion can kill performance in an AI data center.

Arista Networks is still much smaller than networking giant Cisco Systems, but its leading the way in the upper tier of the networking-hardware market. Arista has surpassed Cisco in the 10GbE and higher data-center switch market in terms of ports, and it's nearly surpassed Cisco in terms of dollars.

Arista has generated $6.3 billion in revenue over the past 12 months, and its adjusted operating margin is well above 40%. The company has about 10,000 customers, although one signficant risk is customer concentration. Microsoft and Meta Platforms combined to represent 39% of Arista's sales in 2023.

While this customer concentration is something to be concerned about, the company's flexible, scalable, and software-driven architecture is winning over companies building massive AI data centers. Arista stock is expensive, trading close to 40 times forward earnings. I wouldn't buy it at the current price, but if shares of Arista get driven lower by panic and worry, the stock could make for a great long-term bet.

A cloud giant in the making

Cloudflare does a lot more than secure and speed up websites. The company offers a sprawling catalog of cloud-based products and services, including Zero Trust for user authentication and a full-fledged developer platform. A full cloud application, complete with a serverless database, can be run directly on Cloudflare's network without the hassle of managing servers and other infrastructure.

Cloudflare is still a small company relative to the cloud giants. Revenue reached $401 million in the second quarter, up 30% year over year, and the company is still not profitable on a generally accepted accounting principles (GAAP)d basis. But Cloudflare's position as the go-to for basic security and caching for websites and servers gives it a massive long-term opportunity to convert free users to paid users and to cross-sell additional services to its growing customer base.

The company has more than 210,000 paying customers and an untold number of free users. About half of its revenue comes from outside the United States, and roughly two-thirds comes from more than 3,000 large customers spending at least $100,000 annually on its services. Unlike Arista, Cloudflare doesn't have a customer-concentration problem.

Cloudflare stock is even more expensive than Arista stock, though, trading at over 100 times forward-adjusted earnings. Despite the company's growth potential, that price is far too rich for me.

If a stock market slump brings Cloudflare's valuation back down to earth, I'll be happy to put the stock in my portfolio. But the price has to be right.