Find $\max\{y-x\}$

Note that $y^2=(3-x-z)^2=9-x^2-z^2\implies z^2+(x-3)z+(x^2-3x)=0$ so $$2z=3-x\pm\sqrt3\sqrt{3+x-x^2}\implies y=3-x-z=\frac{3-x}2\mp\frac{\sqrt3}2\sqrt{3+2x-x^2}$$ giving $$\max\{y-x\}=\max\left\{\frac32-\frac32x+\frac{\sqrt3}2\sqrt{3+2x-x^2}\right\}$$ and differentiating gives $$-\frac32+\frac{\sqrt3}4\cdot\frac{2-2x}{\sqrt{3+2x-x^2}}=0\implies (1-x)^2=3(3+2x-x^2)$$ so $x^2-2x-2=0\implies x=1\pm\sqrt3$, and $\max\{y-x\}=2\sqrt3$ when $x=1-\sqrt3$.


Our conditions give $$x^2+y^2+z^2=(x+y+z)^2$$ or $$xy+xz+yz=0.$$ Now, let $y-x=t$.

Thus, $y=x+t$, $z=3-x-y=3-2x-t$ and we obtain that the equation $$x(x+t)+(3-2x-t)(x+x+t)=0$$ has real roots $x$, which says that $\Delta\geq0.$

We obtain: $$3x^2+3(t-2)x+t^2-3t=0,$$ which gives $$9(t-2)^2-12(t^2-3t)\geq0$$ or $$-2\sqrt3\leq t\leq2\sqrt3.$$


By taking the rotation $X=(y-x)/\sqrt{2}$ and $Y=(y+x)/\sqrt{2}$ we have that the equations become $$\begin{cases} X^2+Y^2+z^2=9\\ \sqrt{2}Y+z=3\end{cases}$$ Hence $z=3-\sqrt{2}Y$ and $$X^2=9-(3-\sqrt{2}Y)^2-Y^2=3Y(2\sqrt{2}-Y)\leq 6$$ with equality for $Y=\sqrt{2}$ (and $z=1$). It follows that $$X=\frac{y-x}{\sqrt{2}}\leq \sqrt{6}\implies y-x\leq 2\sqrt{3}.$$ Equality is attained for $x=-(\sqrt{3}-1)$ , $y=\sqrt{3}+1$, and $z=1$.