The stock market has been on an amazing run, with the S&P 500 (^GSPC -0.71%) rising 93% since it bottomed out in March 2020. Before that it was largely on an uninterrupted path higher for well over a decade. 

What that shows is that despite dips and even deep valleys, stocks tend to resume their upward trajectories relatively quickly. And the time we suffer through those declines is far shorter than the bull markets that follow.

Person examining papers with a magnifying glass

Image source: Getty Images.

History tends to repeat itself

After China's biggest property developer Evergrande shook the market when it came to the brink of defaulting on its loans, many have been thinking we may be poised to see the market dip again, or even fall into a worldwide recession.

No one can predict when such an event will occur, but investors should be prepared for it to happen at any time. But the two tech stocks below represent companies investors should be ready to buy if a recession strikes.

Person with headphones looking at laptop

Image source: Getty Images.

Baidu

The Evergrande episode shows just how fragile the economic recovery of the past year has been. While U.S. stock indexes recovered all of the ground they lost, most China-based stocks can't say the same. Internet search giant Baidu (BIDU -0.58%) is a prime example of that, as its shares are still down 3.5% in the week following the Evergrande-induced scare.

Beijing is cracking down on tech-oriented businesses, an outgrowth of the government's desire to limit the free flow of information. Baidu's stock is down 28% year-to-date, and 56% below its 52-week high because of the greater scrutiny China is giving to certain segments of its economy.

Despite the threat, Baidu itself has not been put under the microscope, and there's no indication it's going to be. It scrupulously follows Beijing's orders, and actually benefits from the limits that have been imposed on the competition. Its biggest rival, Google, is not even allowed to participate in the Chinese search market -- yet Baidu is being valued as though its business will never grow further.

As much as I'm leery of recommending any China stocks based on the inherent risks associated with mercurial government policy, Baidu has a dominant market share, making it the prime destination for advertisers. Year-to-date online marketing revenue is up 22% year-over-year, while online advertising service revenue jumped 18% from a year ago.

Because of its reach, Baidu will still be the leading internet search service in China, and its stock seems cheap now. If a recession were to strike, it would become even more so.

Padlock and credit card on computer keyboard

Image source: Getty Images.

Crowdstrike Holdings

Last month, a hacker stole data on 50 million T-Mobile customers. A few weeks ago Apple released an emergency software patch after a security flaw was discovered that allowed hackers to secretly install spyware on Apple devices without the user's knowledge. Suffice it to say that with so much data being moved to and stored in the cloud, cybersecurity is one of the biggest areas of concern for businesses -- and why Crowdstrike Holdings (CRWD -11.10%) will thrive, regardless of market conditions.

Using sophisticated machine learning, artificial intelligence, and behavioral analysis to detect and thwart cybersecurity risks, Crowdstrike's Falcon platform manages trillions of events weekly while providing customers with cost-effective personalization and customization solutions. 

Falcon grows smarter as time progresses, allowing it to recognize and respond to potential threats more quickly. The results resonate with its more than 13,000 customers, 98% of which renew their subscriptions with the cybersecurity specialist. Annual recurring revenue jumped 70% last quarter to $1.3 billion. Customers who four or more modules are growing 30% or more, helping to lift gross margins to 76%.

If the economy spirals down into a recession, Crowdstrike Holdings becomes an easy stock to buy.