Six billion cockroaches are being bred each year through artificial intelligence at a Chinese farm making "healing potions".
If the largest ever colony of cockroaches escapes it would cause a "catastrophe" for the nearly 800,000 people living in nearby Xichang in Sichuan province, central China, one expert warned.
The insects are being bred for a "healing potion" taken by millions of patients in China, the Chinese government said.
The potions have "remarkable effects" on stomach pain and other ailments, the local authorities claim.
Cockroaches have been used for thousands of years in Chinese medicine, but most people buying the potion today do not realise what the ingredients are as its Latin name is used on packaging.
More than 40 million people have been cured of respiratory, gastric and other diseases after taking the potion on prescription, a local government report said.
The pests, which have been around since the dinosaurs, are housed in a large warehouse controlled by artificial intelligence (AI) – with few humans ever allowed inside.
The farm is fully sealed, warm, humid and dark for optimum reproduction.
The cockroaches thrive as the smart system constantly collects and analyses more than 80 pieces of data, including food supply, consumption, temperature and humidity.
Any genetic mutations are monitored, as are every individual insect's growth rate, with conditions automatically altered to improve optimal production.
Dr Zhang Wei, who was involved in developing the AI system, told the South China Morning Post: "There is nothing like it in the world.
"It has used some unique solutions to address some unique issues."
A 2011 government report on the facility said the cockroaches were "everywhere", on shelves, floors and ceilings.
"Hold your breath and you only hear a rustling sound," it said.
"Whenever flashlights swept, the cockroaches fled.
"Wherever the beam landed, there was a sound like wind blowing through leaves.
"It was just like standing in the depths of a bamboo forest in late autumn. The cool breeze blows, and the leaves rustle."
Cockroach farms have been appearing all over China in the past decade but the Xichang farm, run by the Good Doctor Pharmaceutical Group, is by far the largest.
Experts are concerned about what would happen if the cockroaches escaped due to human error or a natural disaster such as an earthquake.
An escape would be a "catastrophe" and would be "terrifying" for Xichang's residents, said Professor Zhu Chaodong, head of insect evolution studies at the Institute of Zoology in Beijing.
"Multiple lines of defence must be in place and work properly to prevent the disaster of accidental release," he said.
He added that because cockroaches multiply incredibly quickly in warm, humid climates like Xichang, just a dozen could infest an entire neighbourhood.
Fears the genetic screening and rapid reproduction at the farm could cause "super cockroaches" are unlikely because they have already survived hundreds of other animals becoming extinct, including the dinosaurs.
More from China
"Every cockroach is a super-cockroach," Mr Zhu said.
"Mother Nature has already done its job. There is little room left for us to make improvents."