Hong Kong (CNN) Less than a month ago, Singapore was being hailed as one of the countries that had got its coronavirus response right.

Encouragingly for the rest of the world, the city-state seemed to have suppressed cases without imposing the restrictive lockdown measures endured by millions elsewhere.

And then the second wave hit, hard. Since March 17, Singapore's number of confirmed coronavirus cases grew from 266 to over 5,900, according to data from Johns Hopkins University

While in the worst-hit countries of western Europe and in the US, thousands of cases are being reported every day, Singapore has a population of 5.7 million people and a total area of around 700 square kilometers -- it is smaller than New York City -- meaning those numbers are more significant.

But Singapore also has advantages that many larger countries don't. It only has one major land border, with Malaysia, and can keep a tight control on people entering by air. It also has a world-class health system and a propensity for somewhat draconian rules and policing that can benefit a government when trying to control a pandemic.

So what went wrong?

The answer appears to lie in overlooked clusters of cases among migrant workers living in cramped dormitories and an underestimation of the speed at which those infections could spread through a city where lockdown measures had not been put in place.

JUST WATCHED Life in lockdown: tips from around the world Replay More Videos ... MUST WATCH Life in lockdown: tips from around the world 03:24

Life as normal

At first, Singapore's status as a small island nation seemed to pay off.

It was able to contain the initial wave of cases from China by instituting quarantines and contact tracing to ensure that anyone arriving by air, who might have been exposed, was isolated and monitored.

At the same time, it ramped up public awareness campaigns to encourage people to take precautions. Isolation wards installed in hospitals in the wake of the 2003 SARS epidemic also meant that patients were treated in the safest way possible, preventing medical staff from becoming infected.

in an opinion piece: "Singapore didn't let positive patients back into the community." Most importantly, wrote Dale Fisher , chair of infection control at the National University of Singapore's hospitalin an opinion piece: "Singapore didn't let positive patients back into the community."

People with few or no symptoms, but who had nevertheless tested positive for the virus were hospitalized until they returned a negative test, rather than put in home quarantine, Fisher said.

By testing widely and isolating all those who were potentially contagious, Singapore was able to remain relatively open and continue functioning as usual.

People wearing masks walk past a temperature screening area at Terminal 1 of Changi Airport on March 22, 2020 in Singapore.

"In Singapore, we want life to go on as normal," Fisher wrote last month, before the latest spike in cases. "We want businesses, churches, restaurants and schools to stay open. This is what success looks like. Everything goes forward with modifications as needed, and you keep doing this until there's a vaccine or a treatment."

That approach stood in stark contrast to Hong Kong: another Asian self-governed city with a similar size population. In Hong Kong, public schools have been closed since February and government employees were encouraged to work from home, though people still traveled around the city relatively freely. New measures were also introduced following an increase in imported cases last month.

Hong Kong has been much more successful in dealing with a second wave.

Singapore only closed schools and some workplaces this month after the most recent spike in cases.

The delay has put the number of new Singapore cases on a much steeper trajectory -- on Thursday it reported 728 new cases -- its largest single day increase. Hong Kong reported four.

Singapore slip-up

Until April, Singapore appeared to be on top of the outbreak.

But clusters that government testing appears to have missed quickly grew and the number of daily cases shot up.

The more relaxed attitude taken in Singapore compared to other countries was only viable if infections from overseas were kept out, and new potential cases were detected and dealt with quickly.

Once this measure failed, the speed at which the virus could pass from person to person was greater than it would be in a place with heavy lockdown and social distancing measures.

Many of the new clusters have been connected to Singapore's vast migrant worker population, in particular those workers -- most from South Asia -- living in cramped dormitories , who appear to have been overlooked in the initial wave of testing. Multiple dormitories have been quarantined and the government is ramping up testing for all workers.

It's unclear whether those infections were from migrant workers coming in from outside, or if the virus was circulating among the largely-untested population for some time. What is evident is that the conditions that workers live in made effective social distancing -- or "home" quarantine -- next to impossible, making it easy for the virus to spread.

"The dormitories were like a time bomb waiting to explode," Tommy Koh, a Singapore lawyer and former diplomat, wrote in a widely-shared Facebook post earlier this month. "The way Singapore treats its foreign workers is not First World but Third World. The government has allowed their employers to transport them in flat bed trucks with no seats. They stay in overcrowded dormitories and are packed likes sardines with 12 persons to a room."

Koh added that "Singapore should treat this as a wake up call to treat our indispensable foreign workers like a First World country should and not in the disgraceful way in which they are treated now."

Since the recent spike in cases, Singapore has instituted what the government is calling a " circuit breaker ," a package of restrictions and new rules, combined with harsh punishments , designed to stymie the new wave of cases and allow the city to get its outbreak back under control.

Singapore has a good chance of getting things under control, thanks again to its small size, strong government, and well-funded healthcare system. But the recent spike in cases in Singapore has lessons for the rest of the world.

No time to relax

Both Singapore and Hong Kong were only able to maintain relative normality while they kept a tight lid on potential imported infections. Once a wave of cases did arrive from overseas, both had to react quickly to prevent a new epidemic.

Hong Kong was able to do this more easily because the city has never completely relaxed, while Singapore has been forced to institute the "circuit breaker," and it remains to be seen how successful that will be.

But this relax-tighten-relax approach to coronavirus restrictions is only really viable in places like Hong Kong and Singapore, where the population size is small enough to be managemable and the specific geography enables authorities to maintain a tight control on who comes in and out, and track their movements if necessary. Hong Kong in particular has instituted mandatory quarantines for those arriving from overseas since mid March

That even these cities have both come close to major second outbreaks, requiring them to again pause their economies and institute sweeping restrictions, should be a major lesson to the rest of the world about relaxing too soon.

As many parts of Asia have already experienced, just because a local outbreak appears to be under control, does not mean a new wave of cases can't be sparked by an infected person entering from overseas.

Until a city or country can be sure that no more infections will come in from outside -- or can be effectively tracked and controlled -- the lack of local cases does not mean the danger has passed.

And in larger countries, where borders between regions are more porous and cities lack the ability to easily control and monitor who comes in and out, avoiding imported infections may be next to impossible -- either the whole country is safe, or nowhere truly is.

As Singapore's experience shows, relaxing too soon can backfire disastrously.