The economy often follows a somewhat predictable if irregular pattern known as the economic cycle. Periods of expansion can often last years before hitting a peak. What follows is a period of contraction -- a recession -- before the economy enters a trough ahead of the next expansion.

Recessionary periods can be brutal for investors. Stock market corrections and bear markets commonly occur during the contraction phase. Cyclical stocks, sold by companies in industries highly sensitive to the economic cycle, are often the hardest hit during a recession.

However, some stock market sectors are relatively immune to the ups and downs of the economic cycle. Here's a closer look at where to invest if you're worried that the economy is about to hit a rough patch.

Economic Uncertainty sign against a stormy background with lightning.

Image source: Getty Images.

Historically recession-resistant industries

Several industries tend to experience relatively steady demand in both good times and bad, making them fairly recession-resistant. These industries include: 

Healthcare

Healthcare stocks tend to be relatively recession-proof. People can't defer most healthcare spending. When you're sick, you need to see a doctor and buy medicine. Some examples of companies in the healthcare industry that tend to do well in recessions are:

  • Johnson & Johnson (NYSE:JNJ): The iconic healthcare company makes well-known products such as Band-Aids and Tylenol, along with medical devices and pharmaceuticals. These products benefit from stable demand.
  • CVS Health (NYSE:CVS): This health company operates a leading drugstore chain, administers a large-scale pharmacy benefits program, and provides health insurance to many people. Demand for those services doesn't change much when the economy falters. 
  • Pfizer (NYSE:PFE): Together with its partners, Pfizer makes some of the world's best-selling pharmaceutical drugs and vaccines covering a wide range of medical issues. People need access to these lifesaving products no matter what's going on in the economy. 
  • UnitedHealth Group (NYSE:UNH): The diversified healthcare company offers a broad array of products and services. These include information and technology-enabled health services, healthcare coverage, and benefit services that people need during economic downturns.
  • Walgreens Boots Alliance (NASDAQ:WBA): This leading global retail pharmacy benefits from relatively steady demand for its products.

Consumer staples

People need to eat even when the economy hits a rough patch. However, consumers tend to shift their eating habits from dining at restaurants to preparing more food at home. Because of that, grocery stores and packaged food makers tend to be highly recession-resistant. Likewise, other consumer staples such as household and personal products tend to experience stable demand in recessions. Some examples of recession-resistant companies that manufacture or sell consumer staples are:

  • Kroger (NYSE:KR): Grocery stores such as Kroger, one of the country's largest supermarkets by revenue, tend to benefit from recessions as consumers cook more often at home.
  • PepsiCo (NASDAQ:PEP): As the maker of the well-known brands Pepsi, Tropicana, Quaker Oats, and Aquafina, all of which are found on grocery store shelves, PepsiCo is well positioned during recessions. PepsiCo's sales tend to remain relatively stable during difficult times.
  • Procter & Gamble (NYSE:PG): The household and personal products company sells familiar brands such as Pampers, Downy, Tide, Charmin, Gillette, Head & Shoulders, Dawn, and Crest -- all of which remain in demand during recessions.
  • General Mills (NYSE:GIS): The leading maker of packaged food products owns beloved brands such as Cheerios, Nature Valley, Blue Buffalo, Häagen-Dazs, Pillsbury, Betty Crocker, Yoplait, and Annie's. These brands never go out of style. Instead, demand tends to pick up when people shift their food spending from restaurants to eating at home.
  • Tyson Foods (NYSE:TSN): One of the world's largest food companies focused on protein, Tyson's brand portfolio includes its namesake, as well as Jimmy Dean, Hillshire Farm, Ball Park, and others. Demand for its products tends to remain steady no matter what's going on in the broader economy. 

Utility companies

Even when businesses close and people lose their jobs during recessions, demand for electricity, water, waste collection, and natural gas remains relatively steady. Because of that, utilities and utility-like companies generate reasonably consistent earnings throughout recessions. Some examples of utility-type companies include:

  • American Water Works (NYSE:AWK): The nation's leading water and wastewater utility company produces steady earnings supported by government-regulated rates.  
  • Brookfield Infrastructure (NYSE:BIPC)(NYSE:BIP): The globally diversified infrastructure company owns utilities, pipelines, power lines, data centers, cell towers, and a range of other infrastructure assets. These businesses generate contractually secured or government-regulated cash flows that remain stable during a recession. 
  • NextEra Energy (NYSE:NEE): This large-scale Florida-focused utility and leading renewable energy producer generates stable revenues secured by government-regulated rates and long-term, fixed-rate contracts.
  • Williams Companies (NYSE:WMB): The natural gas infrastructure giant operates critical pipelines that move gas and other energy commodities from production basins to market centers. Williams' assets generate stable cash flows backed by long-term contracts or government-regulated rates. 
  • Waste Management (NYSE:WM): This waste collection and recycling company generally has steady revenue streams since demand for its services doesn't diminish much in recessions.

Cost-conscious retail

Consumers tend to spend carefully during recessions. Many people begin buying lower-priced items. They also typically eliminate optional expenses such as paying professionals to take care of routine home and car maintenance. Instead, they usually spend more money at dollar stores, home improvement outlets, discount retailers, and auto parts stores. Some examples of retail companies that typically benefit from recessions include:

  • Walmart (NYSE:WMT): The leading chain of grocery and discount department stores tends to benefit from recessions as more consumers shop its "always low prices" to save money.
  • Dollar General (NYSE:DG): Cost-conscious consumers shifting their spending to discount items often buy from this low-priced retailer.
  • Home Depot (NYSE:HD): The leading home improvement retailer benefits from recessions because they spur consumers to tackle more do-it-yourself projects to save money.
  • Costco (NASDAQ:COST): The membership-only warehouse store operator allows customers to save money by purchasing goods in bulk. 
  • Dollar Tree (NASDAQ:DLTR): The leading operator of discount variety stores that include the Dollar Tree and Family Dollar brands benefits as customers become more cost-conscious.
People analyzing their spending.

Image source: Getty Images.

Diversified portfolios better withstand recessions

Recessions are inevitable. Because of that, investors should construct truly diversified portfolios to weather the downturns. The key to creating a diversified portfolio isn't holding several stocks but investing in companies across multiple sectors, including those that are recession-resistant.

Any diversified portfolio should include a mix of fast-growing companies and financially strong blue-chip stocks, which have the financial fortitude to withstand a recession. Blue-chip stocks are attractive to investors during recessions because they typically pay dividends, providing them with a tangible return in the form of income. Blue-chip stocks in recession-resistant industries tend to be especially stable, which can help lessen the blow of a market sell-off or recession.

Add some recession resistance to your portfolio

These days, the hottest stocks are in the technology and communications industries. It's easy to build a portfolio that skews toward these growth-focused sectors by buying stocks related to megatrends such as 5Gstreaming servicescloud computing, and social media.

Unfortunately, these sectors are not immune to recession. An economic slowdown could cause businesses to reduce capital spending, which might cause them to cut back on expensive upgrades to 5G or cloud computing. Companies tend to pull back on advertising during recessions, and that hurts ad-driven sectors such as social media and some streaming services. As previously noted, consumers tend to eliminate extra costs during recessions, which can affect streaming services and other entertainment options.

That's why it's important to diversify your portfolio to better withstand a recession by adding some defensive or countercyclical stocks in the consumer staples, utilities, bargain retailing, and healthcare industries. You can still invest in tech companies, but make sure to offset -- as best you can -- any potential negative impacts of a recession on your portfolio.