Between the founding of ”white” Shanghai by the British and Americans in 1842 and the outbreak of World War 2 the city was marked by an extremely complex web of social divisions based on race, nationality and class. They were at their most complex in the 1920s and 30s when the city contained the greatest national diversity. Because whites controlled the city, their views were the ones represented in its legislation, despite only numbering 30,000 in a population of 2.7 million in 1927.
Racial divisions followed the principles of western ideology, with white people were seen as the pinnacle of evolution, while others were rated lower. In Shanghai, the Chinese formed the bottom of the hierarchy (in other parts of the world different groups held this place), where they were looked down and mistreated due to their ethnicity. Between these extremes could be found the numerous servants from countries such as India and French Indochina.
The Japanese had the same right as whites. This was a result of the Japanese status as a great power holding its own concession, gained from Germany following the end of the first world war. Japan had its own version of racist ideology, placing Japan at the top and on a day to day basis there was little contact between the Japanese and ”real” whites.
Racial divisions weren't as strictly observed in the French Concession as in the International Settlement (the area dominated by the British and Americans.) The Chinese had access to French Parks, unlike the British-American ones, for example.
Class division cut across racial divisions. They were partly based on wealth and partly on hereditary privilege. As an example, the descendants of the original British settlers had some special privileges. At the bottom stood unemployed beggars, closely followed by unskilled laborers, both exclusively Chinese. Above them existed fierce competition and an unclear status hierarchy between the growing Chinese middle class and stateless Russias, Belarussians, Ukranians and others from the old Russian Empire.
Divisions of nationality were primarily between ”white” nations and others. But this pattern was complicated by the strong emphasis placed on citizenship. If you were Danish in Shanghai, your Danish citizenship meant you were fully respected as white and a member of whatever profession you held. Refugees from old Russia on the other hand had lost their citizenship and were thus excluded from polite, white society. This meant that even wealthy, well-educated Russians had as low status as the Chinese in many ways. Many stateless whites had to support themselves through manual labor or engaging in small scale commerce, something quite unusual among the white population. They often had to compete with the Chinese for work. The men were frequently incapable of finding work, forcing their wives and daughters to support the family through prostitution. White men didn't want to demean themselves by hiring stateless prostitutes, which forced these women to accept Chinese customers, further increasing their loss of status.
Despite interaction between the different groups, there was a strong tendency towards insularity so that middle class Chinese only saw other middle class Chinese socially or wealthy Englishmen only met with other wealthy Englishmen. Virtually no members of the white population bothered to learn Chinese and marriage between white and Chinese was almost unthinkable.