For every person who moves to San Francisco, another two start commuting to work here. Traffic is down to a crawl: The average afternoon speed on the roads feeding into the highways has dropped 20 percent in the last two years. And the BART trains are squeezed tight: Since 2012, average morning rush-hour ridership from the East Bay has risen 30 percent.

Signs of distress are plentiful. The Fraternite Notre Dame’s soup kitchen was facing eviction after a rent increase of nearly 60 percent. (It was saved for a year after its plight received worldwide publicity.) Two eviction-defense groups were evicted in favor of a start-up that intended to lease the space to other start-ups. The real estate site Redfin published a widely read blog post that said the number of teachers in San Francisco who could afford a house was exactly zero.

“All the renters I know are living in fear,” said Derrick Tynan-Connolly, a teacher at a high school for pregnant teenagers and young mothers. “If your landlord dies, if your landlord sells the building, if you get evicted under the Ellis Act” — a controversial law that allows landlords to reclaim a building by taking it off the rental market — “and you have to move, you’re gone. There’s no way you can afford to stay in San Francisco.”

Mr. Tynan-Connolly, 52, first came to San Francisco three decades ago, when its origins as a working-class port were still in evidence. The city was a haven of political and sexual tolerance unlike any in America. Now, he and many others feel, it has become something much narrower: a haven for the wealthy.

“The city has the largest budget it ever had,” he said. “But the homeless are still suffering while working-class families, including my students, struggle to find affordable housing and child care. Where are the benefits from the boom that are accruing to the whole city?”

San Francisco has a budget of $8.6 billion and a deficit of $100 million, according to Mayor Lee, who ordered city departments to cut spending by 1.5 percent. The mayor, who did not face any significant opposition for re-election in November, did not have time to be interviewed, a spokeswoman said.