SAN FRANCISCO -- Silicon Valley is having growing pains.

Stanford and Palo Alto, where Bill Hewlett and David Packard formed Hewlett Packard, were long considered the birthplace of Silicon Valley. But as chip and other hardware firms grew up further south, San Jose declared itself the "Capital of Silicon Valley." The area is littered with tech giants, from Apple and HP to Intel, Cisco and eBay.

"In a 15-mile radius you have six of the top 10 technology companies in the world and the largest body of highly successful talent pools," said Jed Yueh, chairman and founder of Delphix, a data virtualization company based in Redwood City -- just south of Belmont, Calif.-based Oracle.

While other places aspire to be "the next Silicon Valley" -- even Cuba hopes to get into the mix -- Yueh said the original has a unique advantage. He calls it a self-sustaining "power cycle" where top universities like Stanford spawn startups that are funded by nearby venture capital firms, then grow to be giants (think Google) that spawn their own spinoffs.

Invent, rinse and repeat.

"I built my first tech company in Southern California, but the second one, Delphix, in the Bay Area," said Yueh. "If you can't get the talent to move to you, you move to where the talent is."

Little room to grow

But the Silicon Valley of old is running out of space and many millennials, the new generation of knowledge workers, want to be closer to, if not in, a city with nightlife and culture. That's led the likes of Google, Yahoo, Cisco and others to open big offices in San Francisco. Spurred by tax incentives, Twitter set up its headquarters in the City by the Bay in 2006, and there it remains.

Magdalena Petrova Twitter's headquarters in San Francisco as seen on February 3, 2017.

Salesforce.com never even wanted to be in Silicon Valley. The company started in San Francisco 18 years ago and never looked back.

"We were born and bred in San Francisco, this is our world headquarters," Elizabeth Pinkham, executive vice president of Global Real Estate at Salesforce, said during a ceremony last week to preview the company's new 61-story office tower. The building is set to open next year. Anchor tenant Salesforce will occupy floors 3 to 30 as well as 60 and 61 and already has offices in two adjacent buildings. The CRM firm, in fact, is the largest tech employer in the city and hopes to have as many as 10,000 employees within three years.

David Needle At the "topping off" ceremony for Salesforce.com's office tower in San Francisco, officials were flanked by clergy offering blessings for the project.

But as Salesforce reaches for the sky in San Francisco, other companies like Apple are looking to spread out across the shrinking amount of commercial real estate farther south. The company's nearly-ready "spaceship campus" championed by the late Steve Jobs includes a 2.8-million-square-foot main building encased in the world's largest panels of curved glass. It's expected to open later this year.

If Apple's new headquarters is the ultimate Silicon Valley campus, it's nothing Salesforce aspires to. "We have an urban, vertical campus," said Pinkham. "We're in the heart of the city where employees go out for lunch and use public transportation. We don't do free lunches (a la Google) and gyms, we're a part of the community."

Apple Apple's new campus will open later this year.

San Francisco Mayor Ed Lee went even farther to extol why his city is a good bet for millennials. "We have this incredible mix of faiths, languages and international cultures in San Francisco. It gives you that sense, if you are developing or designing products, that you're part of the world and having an impact," Lee said in an interview at the Salesforce event. "There's a vibrancy here with different cultures that attracts people. That's why younger workers spend so much money to live here -- they're attracted to the city and our values."

Hardware versus software

Silicon Valley veteran Bruce Karsh thinks San Francisco makes a lot of sense for some tech companies, but not all.

"Silicon Valley started with all these hardware companies doing microprocessors and computers, but when software became big, that was a big break. That's when you started to see these companies head north toward San Francisco, because younger people wanted to be closer to the city and hang out in coffee shops with their MacBooks," said Karsh, who has worked for Yahoo and Google and now works for Pandora in Oakland, another Bay Area urban area attracting tech companies.

"With software and the web development, especially now with cloud services, you don't need a lot of the infrastructure and space that hardware companies need," Karsh said.

Analyst Tim Bajarin agrees. "The big shift was the Internet boom. When the Internet expanded, it became a powerful force that fundamentally changed the need for physical location," said Bajarin, president of Creative Strategies.

Still, the Valley remains a magnet for traditional tech firms. Take Celestica, for example. The global design and manufacturer of advanced hardware opened a new Silicon Valley Customer Experience Center March 29 in Santa Clara. The company also has manufacturing facilities in nearby Fremont and San Jose.

"You can draw a three-mile circle around the new Center and hit the majority of our customers," said Celestica CEO Rob Mionis. The Toronto-based company has factories in 20 locations in 14 countries and 27,000 employees worldwide.

"Silicon Valley is home to many of our customers and partners and future partners," said Mionis. "You add in all the VC money and innovation coming out of the Valley and it's easy to see why we need to be here."

The demand for talent that led some firms to move to San Francisco or open offices there has sometimes yielded mixed results.

Magdalena Petrova The logo in front of Google's San Francisco office as seen on February 10, 2017.

City vs. country life

"Because affordable housing is so spread out, residents of Silicon Valley miss out on a lot of community aspects because it is rare for co-workers to live near each other. This is less true in San Francisco since the goal of these offices is to attract millennials who live in the city," said Brian McClendon, until recently vice president of maps and business platform at Uber. McClendon is moving to his home state of Kansas, but continues as a part-time advisor to the ride-sharing firm and makes regular visits to its San Francisco headquarters.

"The general feeling is that it's now hard to hire engineers in San Francisco," he added. "They're all well-employed, so you're trying to attract non-San Francisco engineers North and that's going to be hard (speaking personally)."

Twenty-six-year-old Shravan Reddy has the best of both worlds: He lives near where he went to school (Stanford) and commutes to Dropbox in San Francisco where he's an engineering manager. "There are way more meetups in the city and it's nice for people who want to go to bars and things like that," said Reddy. "But I prefer the (warmer) weather on the Peninsula and the local gym where I play basketball."

Warning signs

Even as tech firms push into the city, residents of the region are looking to escape. In a recent poll by the Bay Area Council, 40% said they want to move away in the next few years. That's a significant bump from the 33% who said the same thing in 2016.

Even worse, a story on the survey by The Mercury News noted that 46% of millennials want to leave the Bay Area in the next few years. They point to traffic and skyrocketing housing costs as the main reasons.

"It turns out that we were wrong about millennial preferences, the stories were wrong that millennials wanted to live in a hyper-urban environment and that it would be OK to raise families in a condo," said Micah Weinberg, president of the Bay Area Council's Economic Institute. "Millennials are putting off family formation, but when they have a family, they want what their parents had: a house on a nice lot pretty close to work."