When the cyclical nature of the economy does bring a recession, it shouldn't come with a housing crash like in 2008. Still, many cities will be negatively affected, the only questions being which ones and by how much.

"Home prices are high right now, but they're high because there's not enough supply to meet demand, which means there's not a bubble at risk of bursting," Daryl Fairweather, Redfin chief economist, said in a press release. "Most of today's financed homeowners have excellent credit and a cushion of home equity, making them unlikely to default on their mortgage even if their weekly grocery bill grows or their stock portfolio shrinks in the next recession."

Certain metro areas will see falling prices and an oversaturation of homes for sale. Those facing the highest risk tend to be the ones with the higher investor and flipping activity. Others will be relatively safe by comparison, with minimal effects on values.

"If the U.S. enters a recession in the next two years, it will likely be caused by the global trade war. U.S. industries that rely on exports, like the automotive industry and the agricultural industry, would be the most vulnerable and susceptible to layoffs," Fairweather continued. "Homeowners who are laid off may not be able to continue covering their monthly mortgage payment and may be forced to sell their homes. And would-be homebuyers won't feel so confident about making a big purchase when they don't feel confident about their job security or their financial wellbeing. That could cause declines in home prices in markets whose economy depends on global trade, but home prices nationwide are likely to hold steady."

From the tech hub of San Francisco to upstate New York, here's a look at the top 15 housing markets providing the safest harbors in the case of an economic downturn, according to Redfin.

For the analysis, Redfin weighed seven factors: Median home sale price-to-household income ratio, average loan-to-value ratio of recently purchased homes, home price volatility, share of home sales that are flips, diversity of local employment, share of the local economy dependent on exports, and share of local households headed by someone age 65 or older.
No. 15 San Francisco, Calif.
Overall risk score: 42.9%
Home price volatility: 16.6%
Home sale price-to-income ratio: 15.1
No. 14 Kansas City, Mo.
Overall risk score: 42.5%
Home price volatility: 13.8%
Home sale price-to-income ratio: 1.9
View of Kansas City skyline in Missouri, United State
No. 13 Oklahoma City, Okla.
Overall risk score: 41.7%
Home price volatility: 13.8%
Home sale price-to-income ratio: 3.3
A pool stands where the terrorist attack took place in Oklahoma
No. 12 Denver Colo.
Overall risk score: 41.5%
Home price volatility: 10.4%
Home sale price-to-income ratio: 5.8
Denver Cityscape Colorado. Downtown Denver Skyline and the Mile High Stadium. Colorado, United States.
No. 11 Philadelphia, Pa.
Overall risk score: 41.4%
Home price volatility: 13.9%
Home sale price-to-income ratio: 4.8
Liberty Bell and Independence Hall in Philadelphia
No. 10 Minneapolis, Minn.
Overall risk score: 40.8%
Home price volatility: 13.6%
Home sale price-to-income ratio: 3.8
No. 9 New Orleans, La.
Overall risk score: 40.6%
Home price volatility: 9.1%
Home sale price-to-income ratio: 4.4
No. 8 Milwaukee, Wis.
Overall risk score: 40.4%
Home price volatility: 15.1%
Home sale price-to-income ratio: 3.8
No. 7 Columbus, Ohio
Overall risk score: 38.3%
Home price volatility: 10.9%
Home sale price-to-income ratio: 3.6
No. 6 Chicago, Ill.
Overall risk score: 37.9%
Home price volatility: 13.2%
Home sale price-to-income ratio: 3.8
No. 5 Raleigh, N.C.
Overall risk score: 35.2%
Home price volatility: 12.1%
Home sale price-to-income ratio: 4.2
No. 4 Cleveland, Ohio
Overall risk score: 34.6%
Home price volatility: 10.9%
Home sale price-to-income ratio: 3
CLEVELAND - SEPTEMBER 16: Rock and Roll Hall of Fame and Cleveland, Ohio skyline from the harbor walkway
No. 3 Hartford, Conn.
Overall risk score: 33.9%
Home price volatility: 13.1
Home sale price-to-income ratio: 3
No. 2 Buffalo, N.Y.
Overall risk score: 31.9%
Home price volatility: 10.4%
Home sale price-to-income ratio: 2.8
No. 1 Rochester, N.Y.
Overall risk score: 30.4%
Home price volatility: 11.7%
Home sale price-to-income ratio: 2.6
Rochester, New York, USA skyline viewed from the south at dusk with the Genesee River flowing toward the downtown area.