In my state, it is permissible to shoot when a criminal is in the act of a felony that involves bodily harm. So, one possible scenario: if the tactical situation permits, one to the head of the perp to suffice for a "warning shot" and scan the others if they stick around. You have eight shots, now seven. In close quarters you won't have time for a mag change either. No BS warning shots into the air. If they run, you're fine, let them go. If the perp is missed or not dead, he won't be sticking around either. See to the victim. Now call the police and prepare for your life to be swamped by the legal consequences of what you just had to do.
That's only one of a hundred possible scenarios depending on any number of tactical factors. You're not going to come out of it clean if you intervene, and you're not going to be able to live with yourself if you don't. I strongly recommend reading Massad Ayoob's In The Gravest Extreme. It will give you an idea of what using that firearm you're carrying will lead to and how best to prepare for it.
I remember reading this advice from Dave Arnold who experienced real riots and a lot more while he was in Southern Rhodesia. He also was present in the aftermath of some. I know he was in the Rhodesian Army and was a cop but don’t recall if he was a Selous Scout.
Typically a crowd will run away at the sound of the first shot. If they are really hopped up and angry enough, they will kill you no matter what you are armed with and no matter how good you are.