THE Samsung Electronics factory in Thai Nguyen, in northern Vietnam, employs more than 60,000 people. Its three canteens serve some 13 tonnes of rice a day. It churns out more mobile phones than any other facility in the world. It and Samsung Electronics’ other factories in Vietnam produce almost a third of the firm’s global output. The company has invested a cumulative $17bn in the country.

But Samsung is as important to Vietnam as Vietnam is to it. Its local subsidiary’s $58bn in revenue last year made it the biggest company in Vietnam, pipping PetroVietnam, the state oil company. It employs more than 100,000 people. It has helped to make Vietnam the second-biggest exporter of smartphones in the world, after China. Samsung alone accounted for almost a quarter of Vietnam’s total exports of $214bn last year.

All this has been a huge boon to Vietnam’s economy. Despite unflattering reports about working conditions in Samsung’s factories, Thai Nguyen and another nearby province that hosts one, Bac Ninh, have become two of the country’s richest. Restaurants, shops and hotels have mushroomed around their industrial zones. The number of local firms listed as important suppliers to Samsung has increased sevenfold in the past three years.

And Samsung is just the biggest South Korean investor in Vietnam. Of the $108bn of foreign direct investment (FDI) Vietnam has received since it joined the World Trade Organisation (WTO) in 2007, a third originated in South Korea. LG Electronics, another South Korean giant, makes television screens in a $1.5bn factory in the port of Haiphong. Lotte, a South Korean conglomerate, owns a string of supermarkets.

Vietnam received FDI worth 8% of GDP last year—more than double the rate that went to comparable economies in the region. Foreign-owned firms now account for nearly 20% of the country’s output. They have grown more than twice as fast as state-owned enterprises over the past decade, despite the country’s nominally communist government. The economy grew at 7.4% year-on-year in the first quarter of 2018, one of the fastest rates in Asia.

For Samsung, Vietnam provides an attractive alternative to manufacturing in China. Its workforce is young, cheap and plentiful. That once was China’s appeal, but its workers are now seven years older, on average, and more than twice as expensive as Vietnamese ones. The cheap labour lowers costs in Samsung’s factories, giving the smartphone-maker an edge over Apple in less expensive handsets. Other countries in the region tend to export raw materials or components to China, where they are assembled into other products. Vietnam exports mainly finished goods.

Vietnam is also a valuable hedge against Chinese administrative caprice. Last year the Chinese government organised a boycott of South Korean firms and products to punish the South Korean government for deploying an American missile-defence system. Although the system was intended to protect against an attack from North Korea, China complained it could be used to undermine China’s defences too. The boycott, although now over, alarmed South Korean investors.

Vietnam, in contrast, is liberalising its economy to welcome foreign industry. In 2015 the government opened 50 industries to foreign competition and slashed regulation in hundreds more. It sold a majority stake in the biggest state-owned brewer, Sabeco, to a foreign firm last year. Vietnam’s enthusiasm for free-trade deals has made it especially alluring to foreign investors. It is a founding member of the Trans Pacific Partnership, a multilateral trade agreement that includes Australia, Canada and Japan, among others. It is due to sign a trade pact with the European Union soon. The deal it signed with South Korea in 2015 has made it South Korea’s fourth-biggest trading partner.

Moon Jae-in, the president of South Korea, visited Vietnam last month, with business delegates from Samsung and other companies in tow. It was his second trip to the country in less than a year in office. Presidential advisers have expressed the idea that South Korea should not content itself with being a “shrimp among whales” such as China and Japan, but instead become a regional power by embracing smaller allies. That, they claim, would make South Korea more of a “dolphin”, in command of its own fate. In Vietnam, at least, this plan is going swimmingly.