San Francisco has the least affordable housing in the nation, with just 14 percent of homes accessible to middle-class buyers, said Jed Kolko, chief economist at the real estate website Trulia. The median rent is also the highest in the country, at $3,250 a month for a two-bedroom apartment.
"Affordable housing projects are constructed, and the money set aside for that purpose is used, but the demand is just far greater than what can be supplied," said Fred Brousseau of the city budget and legislative analyst's office. Evictions under a provision of state law that allows landlords to evict rent-controlled tenants if they convert a building for sale have more than tripled in the past three years, just as they did during the first tech boom.
To Yelly Brandon, a 36-year-old hairstylist, and her boyfriend, Anthony Rocco, an archivist, the obstacles to finding housing became clear when they spent two months searching for an apartment. At open houses, they said, they were competing with young tech workers, who offered more than the asking price and cash up front.
"People were just throwing money in the air," Ms. Brandon said.
The influx of wealth is, in turn, changing the tenor of neighborhoods. Fort Mason, a renovated military post on the bay, has been nicknamed "Frat Mason" for the 20-something "tech bros" — tech company salespeople, marketing employees and start-up founders — who have moved into luxury apartments there and play bocce on the great lawn.
Nowhere are the changes starker than in the Mission District, once a working-class Hispanic neighborhood, now a destination for the tech elite.
Evan Williams of Twitter and Mark Zuckerberg of Facebook have bought homes near there.
Longtime residents of the Mission District complain that high-end apartments, expensive restaurants and exclusive boutiques are crowding out the bodegas, bookstores and Mexican bars. They complain about workers who, like residents of a bedroom community, board company buses every morning and return every evening to drink and dine on Valencia Street.
And they grumble about less tangible things: an insensitivity in interactions in stores and on the street, or a seeming disregard for neighborhood traditions. The annual Day of the Dead procession, meant to be solemn, has turned into a rowdy affair that many newcomers seem to view as a kind of Mexican Halloween.
"Some of the people in the stores that I knew, they are good people and nice people, and then I see them get evicted and then the people who move in there are not as nice," said Rene Yañez, an artist and founder of Galería de la Raza in the 1970s, who started the procession. Mr. Yañez and his partner, who is battling cancer, are being evicted from the apartment they have occupied for decades.
Evictions are higher in this neighborhood than in any other part of the city.
"They are not only expelling the homeless and the gangbangers," said Guillermo Gómez-Peña, a performance artist. "They are also expelling the performance artists, the poets, the muralists, the activists, the working-class families — all these wonderful urban tribes that made this neighborhood a very special neighborhood for decades."
"One day," he added, "they will wake up to an extremely unbearable ocean of sameness."
(Read more: Traders expect a rocky week for markets—here's why)
Some tech companies are trying to give back. Salesforce has donated millions of dollars to the public schools, and Twitter, which declined to comment on its effect on the city, is providing lawyers to help fight evictions, under an agreement with the city in exchange for tax breaks.