In 2012, Somerville, Massachusetts, was facing what Daniel Hadley, now Mayor Joe Curtatone’s chief of staff, called an “onslaught of rats.”

Year over year, complaints about rats had risen 65 percent. The number of rat-related calls to the city’s hotline in the summers of 2012 and 2013 was more than twice what it had been in 2010. (Rat populations boomed during successive mild winters in the Northeast.) The city of 78,000 north of Boston was under siege, and it responded in kind. Somerville declared war on rats.

Now, rat sightings are down an incredible 66 percent year over year — thanks to data analysis (and new trash cans).

Somerville’s Rodent Action Team (RAT), a group of public health professionals, data analysts and city workers, started by mapping the reported rat sightings — the city was receiving, on average, two rat-related calls a day in 2012. They began to see a pattern. As London’s cholera cases clustered around wells, so Somerville’s rat sightings were concentrated around food sources.

That might seem obvious, but there’s a reason that many municipal anti-rat projects focus on rat reproduction. According to the sterilization company SENES, four male and four female rats can add an incredible 14.5 million rats to the population over their eight-to-nine-month lifetimes. Food sources can seem like a secondary concern. Also around 2012, New York’s Metropolitan Transit Authority conducted a well-reported sterilization experiment in the subways. (Surveys reported a 3 percent drop in rat sightings that year.)

In Somerville, clamping down on food sources (in concert with a tough winter) produced a shocking success.

The city quadrupled the number of waste container licenses it issued to restaurants. It bought 64-gallon trash cans for every house in the city. After all, if residential garbage pickup and disposal is a municipal service, why not garbage storage? Standardizing the city’s bins was first and foremost a RAT initiative, but the result was aesthetically pleasant too.

The primary data source wasn’t exactly high-tech: Rats were only reported by calls to the city’s 311 line. That tended to mean that neighborhoods with high percentages of homeowners were overrepresented in the raw data, while others seemed to have fewer issues. But by looking at rat reports as a percentage of total calls, the city figured it was getting a more reliable geographic portrait. A comparison with neighboring Boston was instructive. The two cities’ rat reports seemed to move in concert, to the point where officials could predict the number of calls in Somerville based on the parallel figure in Boston.

Until this year, that is. After the brutal winter, the snowiest in Boston’s snowy history, experts expected rat populations to take a hit. Boston’s did. But Somerville’s rat population declined 40 percent more than that of its neighbor across the Charles.

We tend to think of such data-driven management as a technique reserved for big cities like Chicago and New York, with their in-house analysis teams. Somerville is bucking that stereotype. The city has a five-person department called SomerStat that offers analytical expertise on matters like the budget and public works. Curtatone, who has been mayor since 2004, said that the city already had the data in hand — it just didn’t have a team to use it.

Skye Stewart, the director of the department, said that resources had previously been allocated based on best estimates or gut feelings. Now, it’s her team — “a bunch of data nerds” — who help out, in turn reducing the city’s dependence on expensive outside consultants.

As the new trash bins were distributed to residents, for example, SomerStat helped the city’s Department of Public Works determine how many residents had overflowing bins, and how that number varied between garbage routes.

“With the right sort of analysis you can … save hundreds of millions of dollars,” said Hadley, who headed up SomerStat for three-and-a-half years before Stewart took over last summer. “In midsize cities, the amount of data is proliferating to the extent that it’s becoming more cost-effective.”

He’s still envious of how a city like New York, which is more than 100 times Somerville’s size, can gather and manipulate information about traffic or crime. Somerville, however, may have set the standard in one field: rat reduction.

With the city receiving just a third as many calls as last year, Hadley was triumphant. “I’ve never seen a drop quite like that,” he said.