Example 12 Given an integer $n \geqslant 2$ and a positive real number $a$, positive real numbers $x_{1}, x_{2}, \cdots, x_{n}$ satisfy $x_{1} x_{2} \cdots x_{n}=1$. Find the smallest real number $M=M(n, a)$, such that
$$\sum_{i=1}^{n} \frac{1}{a+S-x_{i}} \leqslant M$$

always holds, where $S=x_{1}+x_{2}+\cdots+x_{n}$.
First, consider the case where $a \geqslant 1$. Let $x_{i}=y_{i}^{n}, y_{i}>0$, then $y_{1} y_{2} \cdots y_{n}=1$. We have
$$\begin{array}{l}
S-x_{i}=\sum_{j \neq i} y_{j}^{n} \geqslant(n-1)\left(\frac{\sum_{j \neq i} y_{j}}{n-1}\right)^{n} \text{ (Power Mean Inequality)} \\
\geqslant(n-1)\left(\frac{\sum_{i \neq i} y_{j}}{n-1}\right) \cdot \prod_{j \neq i} y_{j} \text{ (Arithmetic Mean} \geqslant \text{ Geometric Mean)} \\
=\frac{\sum_{i \neq i} y_{j}}{y_{i}}.
\end{array}$$

Thus,
$$\sum_{i=1}^{n} \frac{1}{a+S-x_{i}} \leqslant \sum_{i=1}^{n} \frac{y_{i}}{a y_{i}+\sum_{j \neq i} y_{j}}$$

When $a=1$,
$$\sum_{i=1}^{n} \frac{y_{i}}{a y_{i}+\sum_{j \neq i} y_{j}}=\sum_{i=1}^{n} \frac{y_{i}}{\sum_{j=1}^{n} y_{j}}=1$$

And when $x_{1}=x_{2}=\cdots=x_{n}=1$, $\sum_{i=1}^{n} \frac{1}{a+S-x_{i}}=1$, so $M=1$.
Now assume $a>1$. Let $z_{i}=\frac{y_{i}}{\sum_{j=1}^{n} y_{j}}, i=1,2, \cdots, n$, then $\sum_{i=1}^{n} z_{i}=1$.
$$\begin{array}{l}
\frac{y_{i}}{a y_{i}+\sum_{j \neq i} y_{j}}=\frac{y_{i}}{(a-1) y_{i}+\sum_{j=1}^{n} y_{j}} \\
=\frac{z_{i}}{(a-1) z_{i}+1} \\
=\frac{1}{a-1}\left[1-\frac{1}{(a-1) z_{i}+1}\right]
\end{array}$$

By the Cauchy-Schwarz Inequality,
$$\left\{\sum_{i=1}^{n}\left[(a-1) z_{i}+1\right]\right\}\left[\sum_{i=1}^{n} \frac{1}{(a-1) z_{i}+1}\right] \geqslant n^{2}$$

And
$$\sum_{i=1}^{n}\left[(a-1) z_{i}+1\right]=a-1+n$$

Thus,
$$\sum_{i=1}^{n} \frac{1}{(a-1) z_{i}+1} \geqslant \frac{n^{2}}{a-1+n}$$

Combining (46), (47), and (48), we have
$$\begin{aligned}
\sum_{i=1}^{n} \frac{1}{a+S-x_{i}} & \leqslant \sum_{i=1}^{n}\left[\frac{1}{a-1}\left(1-\frac{1}{(a-1) z_{i}+1}\right)\right] \\
& \leqslant \frac{n}{a-1}-\frac{1}{a-1} \cdot \frac{n^{2}}{a-1+n} \\
& =\frac{n}{a-1+n}
\end{aligned}$$

When $x_{1}=x_{2}=\cdots=x_{n}=1$, we have
$$\sum_{i=1}^{n} \frac{1}{a+S-x_{i}}=\frac{n}{a-1+n}$$

Thus, $M=\frac{n}{a-1+n}$.
Next, consider the case where $0 < a < 1$. The function
$$f(x)=\frac{x}{x+\lambda}=1-\frac{\lambda}{x+\lambda}$$

is strictly increasing on the interval $(0,+\infty)$, so $f(a)<f(1)$, i.e., $\frac{a}{a+\lambda}<\frac{1}{1+\lambda}$. Therefore, by the result for $a=1$,
$$\sum_{i=1}^{n} \frac{1}{a+S-x_{i}}=\frac{1}{a} \sum_{i=1}^{n} \frac{a}{a+S-x_{i}}<\frac{1}{a} \sum_{i=1}^{n} \frac{1}{1+S-x_{i}} \leqslant \frac{1}{a}$$

When $x_{1}=x_{2}=\cdots=x_{n-1}=\varepsilon \rightarrow 0^{+}$ and $x_{n}=\varepsilon^{1-n} \rightarrow+\infty$,
$$\begin{aligned}
& \lim _{\varepsilon \rightarrow 0^{+}} \sum_{i=1}^{n} \frac{1}{a+S-x_{i}} \\
= & \lim _{\varepsilon \rightarrow 0^{+}}\left[\frac{n-1}{a+\varepsilon^{1-n}+(n-2) \varepsilon}+\frac{1}{a+(n-1) \varepsilon}\right] \\
= & \frac{1}{a}
\end{aligned}$$

Thus, $M=\frac{1}{a}$. In summary,
$$M=\left\{\begin{array}{ll}
\frac{n}{a-1+n}, & \text { if } a \geqslant 1 \\
\frac{1}{a}, & \text { if } 0<a<1
\end{array}\right.$$