Melbourne soon overtook Sydney as Australia's largest city, leading to an enduring rivalry between the two. However, increased immigration from overseas and wealth from gold exports increased demand for housing, consumer goods, services and urban amenities. The New South Wales government also stimulated growth by investing heavily in railways, trams, roads, ports, telegraph, schools and urban services. The population of Sydney and its suburbs grew from 95,600 in 1861 to 386,900 in 1891. The growing population packed into rows of terrace houses in narrow streets.