Long, narrowly spaced rows of shelves fill a multi-storey building about the size of two sports fields. The shelves are lined with open containers of food and water.

It is warm, humid and dark all year round, with freedom to roam to find food and reproduce. Fully sealed like a prison, it has strict limitations on access to visitors. From birth to death, inhabitants never see the sun.

The world’s largest cockroach farm is breeding 6 billion adult cockroaches a year and using artificial intelligence to manage a colony larger than the world’s human population – all for medicinal use.

It is part of the production process for a “healing potion” consumed by millions of patients in China, according to the government.

There are many cockroach breeding facilities in China, for use as an ingredient in medicine or as a source of protein for livestock feed. But no other facility can match the productivity of the farm in the city of Xichang, in southwestern Sichuan province.

Nearly 28,000 full-sized cockroaches per square foot are produced there annually, the Sichuan government said in a report submitted to Beijing early this year.

It is the first time in history so many cockroaches have been confined and bred in one space. The project had achieved so many “scientific and technological breakthroughs” that it deserved a national science award, the provincial government said.

The facility achieved its unrivalled efficiency partly by being controlled by a “smart manufacturing” system powered by artificial intelligence (AI) algorithms, according to the report.

The system constantly collects and analyses more than 80 categories of “big data”, including humidity, temperature, food supply and consumption. It monitors changes such as genetic mutations and how these affect the growing rates of individual cockroaches.

AI is transforming China in many sectors, from powerful facial recognition systems capable of identifying 1.3 billion citizens in seconds to nuclear submarines that can help a captain make faster, more accurate decisions in combat.

In the cockroach farm, the AI system learns from past work, self-adjusting to improve cockroach production.

Dr Zhang Wei, former assistant researcher at the College of Mechanical Engineering at Zhejiang University, who was involved in the development of the 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.”

Rustling in the darkness

Zhang confirmed the use of AI technology in the project but declined to give details.

The farm is operated by the Gooddoctor Pharmaceutical Group of Chengdu, Sichuan, which confirmed the validity of the government document but could not answer the Post’s queries because the matter involved trade secrets.

According to a 2011 report by the government newspaper Guangming Daily, a visitor must change into a sanitised working suit to avoid bringing in pollutants or pathogens.

“There were very few human beings in the facility,” the article stated. On shelves, floors and ceiling, the cockroaches were “everywhere”.

“Hold your breath and (you) only hear a rustling sound,” it continued. “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.”

Could super-breed terrorise a city?

The sheer number of insects locked in the facility – the largest colony of cockroaches ever to have existed on the planet – conjures some nightmarish scenarios.

Every cockroach is a super-cockroach. Mother Nature has already done its job. There is little room left for us to make improvements

Professor Zhu Chaodong, Chinese Academy of Sciences

Professor Zhu Chaodong, the Institute of Zoology’s lead scientist in insect evolution studies at the Chinese Academy of Sciences in Beijing, said it would be a “catastrophe” if billions of cockroaches were suddenly released into the environment – be it through human error or a natural disaster like an earthquake that damaged the building.

To Xichang’s near-800,000 inhabitants, one such accident could be “terrifying”, Zhu said. The farm is also located close to Xichang’s Qingshan airport.

“Multiple lines of defence must be in place and work properly to prevent the disaster of accidental release,” Zhu said.

Cockroaches multiply rapidly in a suitable environment, said Zhu. Given Xichang’s warm climate and ample rainfall, a dozen of them could infest an entire neighbourhood.

There are also concerns that the farm’s intensive reproduction and genetic screening would accelerate the insect’s evolution and produce “super-cockroaches”, of abnormal size and breeding capability, although Zhu said this was unlikely to happen.

Cockroaches are believed to have been around since the dinosaurs, surviving extreme environmental conditions that brought extinction for other species.

“Every cockroach is a super-cockroach,” Zhu said. “Mother Nature has already done its job. There is little room left for us to make improvements.”

Creating the potion

At the time of the government report, the farm had generated a total of 4.3 billion yuan (US$684 million) in revenue over the years by manufacturing a potion made entirely of cockroaches.

When they reach the desired weight and size, the cockroaches are fed into machines and crushed to make the potion, which had “remarkable effects” on stomach pain and other ailments, said the provincial government.

The potion has a tea-like colour, tastes “slightly sweet” and has “a slightly fishy smell”, according to the product’s packaging.

More than 40 million patients with respiratory, gastric and other diseases were cured after taking the potion on doctors’ prescriptions, according to the official report, which stated that the farm was selling it to more than 4,000 hospitals across the country.

The miracle-like cure

Cockroach has been an ingredient in traditional Chinese medicine for thousands of years. In some rural areas in southern China, infants are still occasionally fed cockroaches mixed with garlic to treat fever caused by an infection or upset stomach.

The Chinese government financed nationwide studies into cockroaches’ medical value that, after more than two decades of laboratory investigation and clinical trials, had discovered or confirmed dozens of disease-fighting proteins and biochemical compounds with huge potential value in medicine.

Thousands of pages of Chinese medical journals have detailed findings suggesting the rejuvenating effect of the cockroach potion. It could stimulate regrowth of damaged tissues such as skin and mucosa, the sticky membrane on the surface of internal organs that is difficult to heal and causes chronic pain.

Patients suffering burns or serious stomach inflammations recovered faster with the potion treatment than without, according to numerous studies.

“The potion is not a panacea – it does not have a magic power against all diseases,” said a researcher experienced in cockroach-related medicines at the Institute of Materia Medica at the Chinese Academy of Medical Sciences (CAMS) in Beijing.

“But its effect on certain symptoms is well established, and confirmed by molecular science and large-scale hospital applications.”

Patients learn the Latin

There is a potentially major disadvantage to the potion, according to the CAMS researcher, who requested not to be named. “The source of raw material, to most people, is disgusting,” she said. “That is an important reason why the use of the potion is not found in other countries.

“Even in China, most patients might not know the liquid came from cockroaches.”

The potion is not for sale over the counter, but the Post has bought it in a drug store in Beijing without being asked for a doctor’s prescription.

A pack containing two bottles of 100ml cost a bit more than 50 yuan (US$8).

On the packaging and in the user instructions, only one ingredient was listed: Periplaneta americana, the Latin name of the American cockroach, one of the largest cockroach species.

The internet has played host to lively discussions about the medicine, known as kangfuxin ye, or “potion of recovery”.

“I searched for Periplaneta americana when drinking the potion. I saw the picture and spat it all on screen,” wrote one user on Baidu Tieba, the large Chinese online community run by search engine company Baidu.

Several patients who had consumed the potion told the Post they were not aware of its content when they drank it.

“This is knowledge I’d rather live without,” said a young mother in Beijing who was prescribed it to accelerate recovery after giving birth a year ago.

“I don’t know the effect, but I healed eventually,” said another patient, who took the potion to cure a back injury.

‘Disgusting but powerful’

Han Yijun, a representative of Gooddoctor Pharmaceutical Group in Beijing, has denied the company misleads patients by referring to the giant cockroach by its academic name.

“Our drug has been used in hospitals for many, many years and established an enormous number of fans,” she said.

Some patients with chronic stomach illness were taking the potion regularly because it could relieve their pain significantly, she said.

“They all know it’s made from cockroaches,” Han said. “It is a disgusting insect, but there are hardly any drugs on the shelves with the same effect.”