Is It Permissible to Pray 30 Rak`ahs in Tarawih?
Question

What is the ruling on praying optional prayers in Ramadan? What is the number of Rak`ahs that it is prescribed to pray in Tarawih? I have seen some deviant groups, such as the Sufis and others, praying Tarawih with thirty Rak`ahs. Is there any evidence for that?
Praise be to Allah.Offering optional prayers in Ramadan
Offering optional prayers in Ramadan, especially voluntary night prayers (Qiyam) , comes under the heading of that which is encouraged, because of the general encouragement to do acts of worship in Ramadan, both prayers and other things, and because the Prophet (blessings and peace of Allah be upon him) recommended praying Qiyam in Ramadan especially. He said: “Whoever prays Qiyam in Ramadan out of faith and in the hope of reward, his previous sins will be forgiven.” (Narrated by Al-Bukhari, 37 and Muslim, 759)
An-Nawawi (may Allah have mercy on him) included it in a chapter entitled: Chapter: Encouragement to pray Qiyam in Ramadan, which is Tarawih. 
So it is encouraged for the Muslim in Ramadan to regularly offer the optional prayers both before and after the obligatory prayers, and to regularly offer Tarawih prayers in congregation with the Muslims. It is also encouraged for him to offer optional prayers in general, except at the times when doing so is disliked. 
How Prophet Muhammad (blessings and peace of Allah be upon him) prayed Tarawih
The Messenger of Allah (blessings and peace of Allah be upon him) did not offer more than eleven Rak`ahs [in Qiyam Al-layl], either during Ramadan or at other times, although occasionally he prayed thirteen Rak`ahs. 
Al-Bukhari (3569) and Muslim (738) narrated from Abu Salamah ibn `Abd Ar-Rahman (may Allah have mercy on him) that he asked `Aishah (may Allah be pleased with her): How did the Messenger of Allah (blessings and peace of Allah be upon him) pray during Ramadan? She said: The Messenger of Allah (blessings and peace of Allah be upon him) did not pray more, in Ramadan or at any other time, than eleven Rak`ahs. He would pray four Rak`ahs, and do not ask how beautiful and long they were. Then he would pray four, and do not ask how beautiful and long they were. Then he would pray three. `A’ishah said: I said: O Messenger of Allah, do you sleep before you pray Witr? He said: “O `A’ishah, my eyes sleep but my heart does not sleep.” 
Al-Bukhari (may Allah have mercy on him) narrated that `A’ishah (may Allah be pleased with her) said: The Messenger of Allah (blessings and peace of Allah be upon him) would pray thirteen Rak`ahs at night, then he when he heard the call for Fajr prayer, he would pray two brief Rak`ahs. 
An-Nawawi (may Allah have mercy on him) said: 
“And it is narrated from `Aishah (may Allah be pleased with her) in Al-Bukhari that he prayed seven or nine Rak`ahs. After that, Al-Bukhari and Muslim narrated the Hadith of Ibn `Abbas that he (blessings and peace of Allah be upon him) would pray thirteen Rak`ahs at night, and two Rak`ahs after dawn, the Sunnah prayer of Fajr. According to the Hadith of Zayd ibn Khalid, he (blessings and peace of Allah be upon him) would pray two brief Rak`ahs and two long ones… and he narrated the Hadith, at the end of which he said: And that was thirteen Rak`ahs. 
Al-Qadi (may Allah have mercy on him) said: The scholars said: In these Hadiths, Ibn `Abbas, Zayd and `A’ishah each spoke of what they saw.”
Is it permissible to pray 30 Rak`ahs in Tarawih?
The Prophet (blessings and peace of Allah be upon him) did not specify any maximum number (of Rak`ahs) for Tarawih prayer , and the matter is broad in scope, in sha Allah. 
So, there is nothing wrong with someone praying more than eleven Rak`ahs, because of the general meaning of the words of the Prophet (blessings and peace of Allah be upon him): “The night prayers are two by two, then if one of you fears that dawn may come, he should pray one Rak`ah, which will make what he has prayed odd-numbered.” (Narrated by Al-Bukhari, 472 and Muslim, 749) 
This is also the view of the jurists of Madhhabs (schools of jurisprudence) in various regions. According to the Hanafi Madhhab it is twenty Rak`ahs, as is also the view of Imam Ahmad. According to Imam Malik, it is thirty-six Rak`ahs, and there is nothing wrong with a person doing any of these options, or others. 
Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said, after mentioning the difference of opinion among the scholars concerning that: 
“The correct view is that all of that is good, as was stated by Imam Ahmad (may Allah be pleased with him), and there is no particular number with regard to Qiyam Al-layl in Ramadan. The Prophet (blessings and peace of Allah be upon him) did not specify any number for that. As that is the case, one may offer more or fewer Rak`ahs, according to how long or short one wants to make the standing. The Prophet (blessings and peace of Allah be upon him) used to make his standing lengthy, as it is proven from him in an authentic narration, in the Hadith of Hudhayfah (may Allah be pleased with him), that he (blessings and peace of Allah be upon him) used to recite in one Rak`ah Al-Baqarah, An-Nisa’ and Al `Imran. Making the standing lengthy suffices instead of praying a greater number of Rak`ahs. When Ubayy ibn Ka`b led them in praying Qiyam, when they were a single congregation, he would not make the standing lengthy for them, so he prayed a greater number of Rak`ahs, instead of making the standing lengthy, and they made the number of Rak`ahs double that of the Prophet (blessings and peace of Allah be upon him), for he used to pray eleven or thirteen Rak`ahs of Qiyam Al-layl. Then after that the people in Madinah grew too weak to make the standing lengthy, so they increased the number of Rak`ahs until it reached thirty-nine.” (Majmu` Al-Fatawa, 23/113; see also 23/120) 
The scholars of the Standing Committee for Issuing Fatwas said: 
“No specific number has been proven with regard to the number of Rak`ahs in Tarawih prayer, and the scholars differed concerning that. Some of them think that it is twenty-three, some think it is thirty-six, some think that it is more and some think that it is less. At the time of `Umar the Companions prayed it with twenty-three Rak`ahs in the mosque of the Messenger of Allah (blessings and peace of Allah be upon him), but the Prophet never prayed more than eleven or thirteen Rak`ahs, whether in Ramadan or otherwise, and he did not set any specific number for the people to pray in Tarawih and Qiyam Al-layl . Rather he used to urge the people to pray qiyam Al-layl and to pray Qiyam in Ramadan in particular. He (blessings and peace of Allah be upon him) would say: “Whoever prays Qiyam in Ramadan out of faith and in the hope of reward, his previous sins will be forgiven”, and he did not specify the number of Rak`ahs, which varies according to the nature of the standing. Whoever makes his prayer lengthy may reduce the number of Rak`ahs, as the Prophet (blessings and peace of Allah be upon him) did, and whoever makes the prayer more brief, out of kindness towards the people, may make the number of Rak`ahs greater, as the Companions did at the time of `Umar. There is nothing wrong with increasing the number of Rak`ahs in the last ten nights of Ramadan, making it greater than in the first twenty nights, and dividing them into two sections, one to be offered at the beginning of the night and made brief, like Tarawih in the first twenty nights, and another section to be offered at the end of the night and made lengthy, to be regarded as Tahajjud. The Prophet (blessings and peace of Allah be upon him) used to pray Tahajjud in the last ten nights as he never did at any other time.” (Fatawa Al-Lajnah Ad-Da’imah, vol. 2, 6/82)
In conclusion, there is no specific number of Rak`ahs for Tarawih prayer, such that it is not allowed to do more or less than that. Whoever prays Tarawih with thirty Rak`ahs, or more or less than that, there is no blame on him, and he is not innovating by doing that. 
Shaykh Ibn Baz (may Allah have mercy on him) said: 
“There is no specific number for Tarawih prayer . Whoever prays twenty, there is nothing wrong with that; whoever prays thirty, there is nothing wrong with that; whoever prays forty, there is nothing wrong with that; whoever prays eleven, there is nothing wrong with that; whoever prays thirteen, there is nothing wrong with that; and whoever prays more or less than that, there is nothing wrong with that. The matter is broad in scope.” (Fatawa Nur `Ala Ad-Darb (9/437) 
And Allah knows best.