For quite some time now, the talk surrounding the economy has centered on whether the U.S. is headed for a recession. If a recession occurs, the best thing you can do as an investor is be overprepared instead of underprepared.

Part of being prepared is determining which stocks make good buys during such times -- and not because their stock prices will be guaranteed to rise, but because of their fundamental businesses. Here are three top tech stocks to consider.

1. Microsoft

Microsoft (MSFT -2.45%) may not be the most valuable tech company (that'd be Apple), but a legitimate argument could be made that it's the most important -- especially to the business world. Countless companies of all sizes, industries, and locations depend on Microsoft for their daily operations, which is why it's as recession-resistant of a tech stock as you'll find.

When the economy is hurting and businesses are trying to cut back on expenses, they often cut back on things like marketing and recruiting. You likely won't see them cut back on how much they're spending with Microsoft because its products and services are integral to their operations. It's much easier to cut back on Facebook ad spending than cloud services in today's online-dominant world.

Microsoft also benefits from having really diverse revenue streams. It has cloud services, Office products, LinkedIn, Xbox, Windows, search advertising, devices, and much more. Of its $52.8 billion in Q2 FY23 revenue, no segment accounted for over 38%. For perspective, the iPhone itself accounts for well over 50% of Apple's revenue.

Regardless if one area of Microsoft's business is affected by a recession -- like companies spending less on LinkedIn services or Xbox sales slowing down -- it shouldn't affect the overall business much. Microsoft is in good shape to weather any storms that head its way.

2. CrowdStrike

Cybersecurity company CrowdStrike (CRWD 0.13%) was a major beneficiary of the mid-2020 to late-2021 bull market, with the stock increasing over 600% between March 2020 to November 2021. It has since lost over 55% of its value, but that should be enticing to investors who shied away from it while it was considerably overvalued.

What makes CrowdStrike a good buy during a recession has a lot to do with the recession-proof industry it operates in. As the world has transformed online, cybersecurity has become a mandatory expense for many businesses. It's like insurance to help protect them from the considerably higher cost of cyberattacks such as data breaches (financially and reputationally).

CrowdStrike has become a formidable player in the cybersecurity industry, adding customers at an impressive rate. At the end of its fiscal 2018, it had 1,242 customers. This number more than quadrupled to 5,431 in 2020, and as of Jan. 31, it has 23,019.

Although the company is much "cheaper" now than in the past couple of years, it still needs impressive growth to justify its price-to-earnings ratio. However, this shouldn't deter long-term investors, considering the projected growth of the global cybersecurity industry: a 13.4% compound annual growth rate through 2029.

3. AT&T

After a rough past five years that's seen its stock price cut by over a third, things seem to be changing for AT&T (T -1.37%). While the S&P 500 is down over 8% in the past 12 months, AT&T is up over 4.5%.

The company is also adding customers at an impressive pace. In last year's fourth quarter, AT&T added 656,000 new postpaid phone customers, more than triple that of Verizon.

AT&T benefits from a telecom industry that has become indispensable. Telecom services -- whether phone, internet, satellite, or the like -- have become increasingly necessary in American life, making it a consumer staple instead of consumer discretionary. If a recession hits, consumers may cut back on entertainment, eating out, and shopping, but you'd be hard-pressed to find someone who would give up having a working phone.

AT&T's dividend ($1.11 yearly per share) also makes it easier for investors to stomach the increased volatility that could come with a recession. Regardless of whether AT&T's stock price goes up or down, investors can feel confident they'll be rewarded either way.