Rav Asher Weiss in his Minchas Asher 3:122*was asked this question . He answers there are 3 categories of pikuach nefesh:
1) When there is a complete danger to the savior according to most poskim it is prohibited to put yourself at risk.
2) When there is a danger present ,but not a major danger then it is middas chassidus to save ones friend.
3) When the danger is very low and negligeable there seems to be even an obligation to save ones friend.
At the end of the Teshuva Rav Asher Weiss notes that during war time the halachos of pikuach nefesh is different ,and he also explains that this applies to those who are in the occupation of saving lives. Therefore, it is permissible and even required for doctors to cure the sick even when the patients are contagious (the teshuva mentioned ebola). See the teshuva inside for more info.
*In Minchas Asher 1:115 Rav Asher Weiss explains that this issue is a machlokes achronim in CM 426 . The Beis Yosef brings the shitta of the Yerushalmi that one is obligated to to put himself in questionable danger in order to save his friend who is in complete danger . However, the Shulchan Aruch does not bring this halacha ,and the Sma(2) notes its absence as proof that its not the halacha.
This was in regards to ,does one have an obligation ,the question is can one do so voluntarily? The Radbaz 3:627 writes that one is a chassid shoteh and it seems that it is assur,see Igros Moshe YD 2:174 .
The Radbaz 5:1582 notes that it depends on the percentage of the danger. If the level of being safe is greater then it's considered a middas chassidus, but if the level of not being safe is higher than its prohibited.
There is a novel opinion from the Ohr Hachaim Rishon Ltzion 155,and Shu"t Halachas Katanos 1:229 that even according to Rabbi Akiva who's says that your life comes before your friends is only voluntarily, and not an obligation. Therefore, if one wants to give up his life to save his friend its is allowed. However, this is not according to the majority of poskim.