Duha Prayer: How Many Rak`ahs?
Question

How many rak‘ahs are there in Duha prayer? I heard that the minimum is two rak‘ahs and the maximum is eight; what is the evidence for that? Should this prayer be done two by two?
Praise be to Allah.The minimum number of rak’ahs for Duha prayer 
The minimum number that has been reported in the case of Duha prayer is two rak‘ahs. Muslim (720) narrated from the hadith of Abu Dharr (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “…and two rak’ahs offered in the forenoon (Duha) will suffice for that.”
Al-Bukhari (1981) and Muslim (721) narrated from the hadith of Abu Hurayrah (may Allah be pleased with him) that he said: “My close friend (blessings and peace of Allah be upon him) advised me to do three things: to fast three days of every month, to pray two rak‘ahs of Duha, and to pray Witr before going to sleep.”
The maximum number of rak’ahs for Duha prayer 
With regard to the maximum number of Duha prayer , there is no text that defines that, but it is proven that the Prophet (blessings and peace of Allah be upon him) prayed Duha with four rak‘ahs, and with more than that, and with eight rak‘ahs, as on the day of the conquest of Makkah. 
Muslim (719) narrated that Mu‘adhah (may Allah have mercy on her) asked ‘Aishah (may Allah be pleased with her): How many (rak’ahs) did the Messenger of Allah (blessings and peace of Allah be upon him) pray in Duha? She said: Four rak‘ahs, and however many more he wanted. 
Muslim (336) narrated that Umm Hani (may Allah be pleased with her) said: The Messenger of Allah (blessings and peace of Allah be upon him) got up to do ghusl, and Fatimah screened him. Then he took his garment and wrapped it around himself, then he prayed eight rak’ahs of Duha prayer. 
Scholarly views on the number of rak’ahs for Duha prayer
It says in al-Mawsu‘ah al-Fiqhiyyah (27/225): “There is no difference of opinion among the fuqaha who say that Duha prayer is mustahabb with regard to the minimum number of rak‘ahs being two. Abu Dharr (may Allah be pleased with him) narrated that the Prophet (blessings and peace of Allah be upon him) said: “…and two rak’ahs offered in the forenoon (Duha) will suffice for that.” So the minimum for Duha prayer is two rak‘ahs, because of this report.
However they differed concerning the maximum. 
The Malikis and Hanbalis are of the view that the maximum for Duha prayer is eight rak‘ahs, because of the report narrated by Umm Hani (may Allah be pleased with her), according to which the Prophet (blessings and peace of Allah be upon him) entered her house on the day of the conquests of Makkah and prayed eight rak‘ahs. (She said:) and I never saw any prayer that was more brief than it, although he bowed and prostrated perfectly. 
The Hanafis and Shafi‘is – according to the more correct view – and Ahmad, according to a report narrated from him, are of the view that the maximum for Duha prayer is twelve rak‘ahs, because of a report narrated by at-Tirmidhi and an-Nasai, with an isnad in which there is some weakness, according to which the Prophet (blessings and peace of Allah be upon him) said: “Whoever prays Duha with twelve rak‘ahs, Allah will build for him a palace of gold in Paradise.”
The correct view is that there is no specific maximum number for Duha prayer; rather a person may pray as many rak‘ahs as he wants, so long as this prayer is done two rak‘ahs by two. 
Shaykh Ibn Baz (may Allah have mercy on him) said: 
“The minimum – for Duha – is two rak‘ahs, and there is no maximum number. But the Prophet (blessings and peace of Allah be upon him) prayed two and four rak‘ahs, and on the day of the conquest of Makkah he prayed Duha with eight rak‘ahs, on the day on which Allah granted him the conquest of Makkah. So this matter is broad in scope. Whether a person prays eight or ten or twelve rak‘ahs, or more than that, or less, there is nothing wrong with it, because the Prophet (blessings and peace of Allah be upon him) said: “The (Sunnah) prayers of the night and day are two (rak‘ahs) by two.” The Sunnah is to pray two by two, saying the salam after each two rak‘ahs.” (Majmu‘ Fatawa Ibn Baz, 11/389)
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said: 
“The correct view is that there is no maximum limit, because ‘Aishah (may Allah be pleased with her) said: The Prophet (blessings and peace of Allah be upon him) used to pray Duha with four rak‘ahs, and however many more he wanted. Narrated by Muslim. And she did not mention any limit. If a person prayed forty rak‘ahs, for example, between the time when the sun reaches the height of a spear and just before the sun reaches its zenith, all of that would be included under the heading of Duha prayer.” (Ash-Sharh al-Mumti‘, 4/85) 
Note: nafl (supererogatory) prayers are to be offered two rak‘ahs by two, whether that nafl prayer is offered by night or by day. Please see the answer to question no. 45268
And Allah knows best.