Recessions are a fact of life for investors and everyone else who lives in a modern economy, even if our experts and pundits don't always agree on exactly what one is and if one's ending or about to begin.

Generally, a recession is defined as two consecutive quarters of falling real GDP, and while you've likely been told for months that one is currently on the way, it hasn't happened yet. The possibility remains, of course, though experts rate the probability of a recession happening in the near term as low as 33% to as high as 61%.

A stack of newspaper pages shows the headline "Recession Fears"

Image source: Getty Images.

And what will it look like when it does happen? Jobs are lost, consumer spending falls, and the stock markets tumble, among other things. But no two recessions look exactly alike in terms of their causes, effects, and duration.

The resulting market volatility can leave investors vulnerable. Fortunately, there are sectors and companies that can act as a safe harbor during such downturns.

Recession-resistant industries and your own economic moat

Recession-resistant industries are a great way to fill your own economic moat. How to start? Consider looking at your own daily life for guidance on what sectors tend to hold up when the economy goes down.

After all, consumer spending makes up about two-thirds of total economic activity in the United States. What do you spend your time and money on?

The first thing that jumps to mind might be consumer staples, a broad category that includes food and beverages, personal care products, and other household goods that people need regardless of the state of the economy.

Included in this vast group are manufacturers like Procter & Gamble and Colgate-Palmolive, and retailers such as Walmart, Kroger, and Dollar General.

Healthcare is another consistent necessity. Here, companies like Johnson & Johnson, Pfizer, and equipment giant Medtronic merit consideration, as do the major private insurers such as UnitedHealth and Cigna.

Then, there's the energy sector and its long list of oil and gas and utility titans such as Chevron and Consolidated Edison.

The latter is an original member of the New York Stock Exchange, dating back more than 150 years. It's probably safe to assume New York City is going to continue needing electricity. Con Ed has also raised its dividend every year for a half-century running, a growth streak that has survived many recessions.

Gold bugs and trusting in real estate

Finally, you can join the gold bugs, who can be particularly active during recessions. Precious metals have a very long history as a safe haven when other assets lose value.

You can buy gold and silver physically, shares of mining companies like Newmont, or indexed, exchange-traded funds like SPDR Gold Trust.

Another sector that offers tangible assets that can attract investors in times of uncertainty is real estate. Specifically, real estate investment trusts (REITs) cover every corner of commercial or residential real estate while offering shareholders attractive dividend payouts.

REITs like Realty Income have portfolios of retail properties occupied by the most reliable of big-name, investment-grade rent payers. Others have specialized niches that can also hold up well during an economic downturn -- Getty Realty, for example, owns more than a thousand gas stations, car washes, auto parts shops, and convenience stores.

Diversification can reduce the risk --  timing, not so much

While no industry or company is completely immune to the vagaries of the economy or the stock market, a combination of solid, recession-resistant companies, index funds, bonds, and maybe some real estate will provide the diversification that can help reduce your losses in a recession.

Investing will always come with some level of risk, and recessions will come and go. Trying to time those can be as futile as timing the market itself.

"The stock market has predicted nine out of the last five recessions," the economist Paul Samuelson famously noted. So while you don't know when they're coming, you can prepare yourself in ways that will help bolster your portfolio through bad times and still profit nicely when times are good.