First of all it is to be noted that Tarawih prayer is a Sunnah that is highly recommended. In the Hadith reported by Salman Al-Farisi (may Allah be please with him), the Prophet (peace and blessings be upon him) addressed the people saying: “O people a blessed and holy month comes to you spreading its shade on you, a month in which Allah made fasting obligatory and staying up at night in worship (i.e. performing Tarawih) as an optional act. In this month there is a single night which is better than one thousand months…”
Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: As far as Tarawih is concerned, it is a nafl or a recommended prayer and there is no fixed number for it. When the Prophet (peace and blessings be upon him) was asked about optional night prayer he replied: “One should perform the night prayer two rak`ahs, then two rak`ahs, etc. And when he feels the arrival of the dawn he should close it off by offering witr, even if it is by praying one rak`ah.”

Traditionally, Muslims have prayed 8 rak`ahs or 20, or 30, or 40 rak`ahs in various circumstances. So, as Imam Ibn Taymiyyah said, it is up to the decision of the Imam and the worshippers; if they can perform 8 rak`ahs while reading the same portion of the Qur’an that one would read while praying 20 rak`ahs, they may do so. However, if the Imam feels that the congregation cannot endure long recitation with fewer number of rak`ahs, he can increase the number of rak`ahs and reduce the portion of recitation in each rak`ah.

In conclusion, we can say that the Prophet’s way of offering optional prayer at night through the whole year can be applied to Tarawih Prayer, by virtue of analogy.