In the short run, there's no telling what an individual stock will do. Shares of terrible companies can rally, and shares of great companies can crumble.

In the long run, a stock's performance is ultimately tied to the underlying company's performance. A company that grows revenue and profit for years on end is likely to produce a solid result for investors. While there are no guarantees, Twilio (TWLO 1.47%) and DigitalOcean (DOCN 3.30%) look capable of doing exactly that.

Twilio

Cloud communications provider Twilio has done an about-face this year. Growth has slowed dramatically amid a tough economic backdrop, putting an end to Twilio's growth-at-all-costs era. Profitability is no longer something that can be ignored.

Twilio is still growing revenue, but not nearly as fast as it used to. Total revenue jumped 10% year over year in the second quarter, driven by 10% growth in the core communications segment and 12% growth in the smaller data and applications segment.

However, existing customers are not eager to expand. The dollar-based net expansion rate in the communications segment was just 103%, while this critical metric was 99% in the data and applications segment. In other words, Twilio is essentially treading water with its existing customer base and relying on new customers to drive most of its growth.

Twilio's core business is usage-based, so the company is going to feel it when customers experience slowdowns of their own. With growth hard to come by, Twilio has shifted gears to focus on profitability. It's a welcome shift for a company that has been the poster child of profitless growth for years.

Importantly, Twilio is driving toward GAAP profitability. The company already produces positive non-GAAP earnings, but that metric backs out stock-based compensation. Twilio is aiming to reach GAAP profitability by 2027 while bringing down its stock-based compensation expense as a percentage of revenue to more reasonable levels. The company is also shooting to return to 15% to 25% annual organic revenue growth by 2025.

Valued at around $11 billion, Twilio stock trades for less than 3 times the average analyst estimate for full-year revenue. That seems reasonable given the company's slower growth rate and its potential to start churning out real profits.

DigitalOcean

Shares of cloud computing provider DigitalOcean tumbled after the company guided for a harsh slowdown going into the second half of the year. DigitalOcean now expects revenue to grow by just 18% in 2023, even with a full year of revenue from Cloudways, the managed hosting company it acquired toward the end of last year.

The core problem for DigitalOcean and the cloud infrastructure industry in general is that customers are growing increasingly cautious. They're less likely to expand usage, and they're actively looking for ways to cut down on their cloud bills. DigitalOcean's net dollar retention rate dropped to 104% in the second quarter, meaning that the existing customer base is contributing little in the way of revenue growth.

The good news is that DigitalOcean's customer base is largely staying put. The company's churn rate is no worse than it was prior to this downturn. DigitalOcean's strategy of keeping its platform simple to use and its pricing transparent and predictable is still a winning formula.

While growth will be slower for now, DigitalOcean's long-term opportunity remains intact. The company sees its total addressable market growing to $195 billion by 2026, and the recent acquisition of AI start-up Paperspace will give DigitalOcean a presence in the fast-growing market for AI cloud infrastructure.

DigitalOcean expects to generate around $140 million in free cash flow this year, putting the price-to-free-cash-flow ratio at just 22. That looks like a steal when you factor in the company's long-term growth potential.