City walls were constructed and re-constructed totally 646 times in Ming Shanxi. The most active three periods were the turn of Zhengtong (正統) and Jingtai (景泰), the mid-Jiajing (嘉靖), and the early Longqing (隆慶). It was primarily a response to the Mongol invasion in Ming Shanxi frontier. During the latter part of Ming period, suburban settlement and its people flourished as a result of urban economy growth in Shanxi. For the purpose of defense, the number of the guanxiang city walls (關廂城) were increased to protect those suburban settlements. Workers were organized by local government. But, in the construction of city wall, the role which gentry as a local elite group played was more and more important.