T HE SLEEK offices of NetEase in Hangzhou, a traffic-clogged city in eastern China, seem an unlikely place to find a farmer. Yet the video-gaming company also runs a pig-rearing division. Ni Jinde launched Weiyang, its swine affiliate, almost a decade ago, after a stint in its financial team. At a state-of-the-art farm in nearby Anji county, Mr Ni oversees the rearing and slaughter of 20,000 organic free-range hogs a year, with the aid of tracking sensors, big-data analysis and soothing music. A second farm, to open in December, will raise another 150,000.

NetEase has become part of a gigantic agricultural venture. China’s 430m porkers account for over half of the world’s herd, and its $1trn industry produces more pork than any other country. Yet pig-rearing remains remarkably inefficient. It has long been a family affair: nine in ten of an estimated 40m pig farmers are thought to raise fewer than 50 hogs a year. Only about one in five Chinese sows is in industrialised production, estimates Bill Christianson of Genus, a British firm that is the world’s biggest supplier of breeding pigs.

But small-scale farms lack measures to prevent the spread of disease; this has allowed a deadly swine fever to run riot since a first reported case in August. In 2013 over 16,000 carcasses of pigs dumped by farmers were dredged from a river that supplies tap water to Shanghai. Since then, new pollution standards that ban livestock production near water sources or towns, and which require proper treatment of manure, have led to closure for tens of thousands of smallholdings.

The closures are likely to accelerate China’s transition to modern production. Large-scale experiments in pig-rearing are under way in the form of multi-storey farms. A complex on Yaji mountain in southern China has 13 levels, with 1,000 pigs to a floor. But these structures are pricey, partly because of the measures they require to prevent disease from tearing through the building.

China’s internet giants think that bringing technology to the pigsty is the answer. Mr Ni says that farms like Weiyang are “setting the example”. It prides itself on rearing its hogs for 300 days in clean and wholesome conditions before they are sent to slaughter, twice as long as the typical life of a Chinese pig. This makes for tastier pork sausages and other pig products it sells online. NetEase is not alone in marrying tech and animal husbandry. JD. com, an e-commerce firm that is an investor in Weiyang, raises and sells “jogging chickens” that each take 1m steps before the chop, making the meat more succulent than that of sedentary fowl. In June the cloud-computing arm of Alibaba, an internet company based in Hangzhou, unveiled an “agricultural brain” that helps farmers monitor pigs in real time through visual and “voice” recognition powered by artificial intelligence.

Alibaba’s programme, which is undergoing tests in Sichuan province, picks up the squeal of a crushed piglet or the bleat of a sick sow, and alerts the farmer. Cameras in the pens track daily activity and vital signs by way of numbers stamped on the animals’ backs. It uses this trove of data to draw up exercise regimes. It reckons that its system can increase to 32 the number of piglets per sow per year, a measure of efficiency in the pig business. That would double the output of many Chinese farms.