The quality of teaching is the most important ingredient in Shanghai's success in education, according to a study by the World Bank.
Pupils in the Chinese city have been ranked in top place in international school tests, and the World Bank, which provides financial and technical assistance to developing countries, has published a report investigating Shanghai's academic success.
It found the standard of teaching was the biggest advantage, including a system of constant teacher training and upgrading of skills.
Teachers in Shanghai, on average, spend only a third of their time teaching - with most of their time being spent on training, preparation and working with mentors.
There are "stringent" requirements to get into teaching, which is seen as a prestigious job, and even though teachers can be dismissed, the study found that, in practice, this was rare.
Instead, there was a system with a very strong emphasis on training and a career built on incentives for the best teachers.
Teachers can receive as much as 30% of their pay in merit payments, decided at school level, on top of a basic salary.
Head teachers are expected to carry on teaching and part of their pay is linked to their school's performance.
There are incentives for teachers and head teachers to work in tougher underperforming and rural schools - such as helping their careers to advance more quickly.
And there can be rotations of teachers working in the most disadvantaged schools.
The World Bank also found that Shanghai benefited from an "entrusted school" system in which stronger schools were "twinned" with weaker schools and expected to raise their standards.
Shanghai, with a population of more than 23 million, has its own devolved education system, which enters the international Pisa tests in its own right.
The most recent tests, run by the OECD, have put Shanghai in top place for maths, reading and science in a global league table of countries and regional school systems.
Report author Xiaoyan Liang said: "One of the most impressive aspects of Shanghai's education system is the way it grooms, supports, and manages teachers, who are central to any effort to raise the education quality in schools."
She said the high level of public respect for teachers in Shanghai was another reflection of "how well they teach. They are true professionals".
Shanghai's population is significantly better educated than the national average for China.
But it also has substantial numbers of poorer pupils - and the report highlights how well these disadvantaged pupils perform in school.
The OECD's education director Andreas Schleicher has shown that in maths tests the poorest 10% of pupils in Shanghai are as good as the most privileged 20% of teenagers in the UK and the United States.
The World Bank report describes Shanghai as having "one of the most equal education systems" in the world, as well as the highest achieving.
The study shows high levels of migrant pupils in Shanghai, who have come with their families from other parts of China. Almost half of the 1.2 million pupils in primary and lower secondary years were classified as migrants.
Most of these were found places in state schools, but almost a quarter were being taught in private schools, with fees paid by the local authority.
About 10% of pupils in the city are taught in private schools.
The Shanghai state school system uses academic selection - with pupils dividing after nine years of basic education into academic and vocational streams, based on point scores in exams.
Within the academic stream there are further divisions, with some sought-after schools being seen as the route to the most prestigious universities.
Schools are expected to deliver a common curriculum, but about 30% of the timetable can be decided by individual schools.
The study highlights how the system delivers high test results.
But there are other social factors to be considered. There is no accountability to parents in this system or mechanism for challenging the decisions of schools or education authorities.
And there are also questions about the pressure this highly competitive, exam-focused system puts on pupils. As well as public examinations, the school system has many internal tests and assessments.
And there have been warnings about the lack of "emotional well-being" that comes with such a concentration on success in exams.
Shanghai, which has linked economic ambition with investment in education, has been used as an example for other countries wanting to raise school standards.
This week, representatives from 25 developing countries, including Brazil, Afghanistan and Ethiopia, are visiting schools in Shanghai to examine ways of improving their education systems.
Harry Patrinos, manager of the World Bank's education sector, said: "High quality schooling is directly linked to strong economic growth and swift poverty reduction, so insights from Shanghai's success could go a long way in a world where as many as 250 million children cannot read or write despite having been to school."