After serving a tour in the sticky rice and fruit fields of northeast Thailand for the Peace Corps, Leanne Spaulding landed a job at a Virginia-based trade association, working her way to a master’s degree from Duke University in environmental management.

Now Ms. Spaulding is in New York, where she was recently hired by the city’s Sanitation Department.

Her duties, naturally, involve garbage, but not in the traditional sense: Ms. Spaulding is trying to help sell residents of the nation’s largest city on its ambitious composting effort. In that respect, her job is like thousands of others added in recent years that are slowly changing the day-to-day face of government service.

There are now nearly 294,000 full-time city employees, more than at any point in the city’s history. The growth under Mayor Bill de Blasio comes at a time of record revenues in a booming city, and has been across the board; nearly every city agency now employs more workers than it did in 2014, when the mayor took office.

The hiring has allowed the de Blasio administration to restaff agencies that were cut back by Mayor Michael R. Bloomberg after the economic downturn of 2008. But Mr. de Blasio has gone far further, expanding the work force beyond its pre-recession peak, a costly investment that is not without risk: the city could be vulnerable to an economic downturn.