Example 12 Let $x, y, z$ be real numbers, not all zero, find the maximum value of $\frac{x y+2 y z}{x^{2}+y^{2}+z^{2}}$.
$$
\begin{array}{c}
\text { Sol: } x y+2 y z=2\left(\sqrt{\frac{a}{2}} x\right)\left(\sqrt{\frac{1}{2 a}} y\right)+2(\sqrt{b} \\
y)\left(\sqrt{\frac{1}{b}} z\right) \leqslant\left(\frac{a}{2} x^{2}+\frac{1}{2 a} y^{2}\right)+\left(b y^{2}+\frac{1}{b} z^{2}\right)= \\
\frac{a}{2} x^{2}+\left(\frac{1}{2 a}+b\right) y^{2}+\frac{1}{b} z^{2} . \\
\text { Let } \frac{a}{2}=\frac{1}{2 a}+b=\frac{1}{b} \text {, solving gives } a=\sqrt{5}, b=\frac{2 \sqrt{5}}{5} .
\end{array}
$$

So $x y+2 y z \leqslant \frac{\sqrt{5}}{2}\left(x^{2}+y^{2}+z^{2}\right)$. The equality holds if and only if $10 x=2 \sqrt{5} y=5 z$. Therefore, the maximum value of $\frac{x y+2 y z}{x^{2}+y^{2}+z^{2}}$ is $\frac{\sqrt{5}}{2}$.