Founded in the 10th century, the city was located in a swampy area east of Suzhou. Until 1127, Shanghai was a small market town of 12,000 households. That year, however Kaifeng was conquered and many refugees came to Shanghai. As a result, the city soon grew to 250,000 inhabitants.
The Shanghai region became one of China's most prosperous in the 13th century, after becoming a cotton production and manufacturing center. The processing of cotton utilized a cotton gin similar to that created by American Eli Whitney. Cotton production and textile milling were the backbone of Shanghai's economy until the early 19th century. The construction of Canals, dikes and real estate development were financed with private capital beginning primarily during the Song dynasty.