2. Let the set $\left\{\left.\frac{3}{a}+b \right\rvert\, 1 \leqslant a \leqslant b \leqslant 2\right\}$ have its maximum and minimum elements as $M$ and $m$, respectively. Then the value of $M-m$ is $\qquad$.
$2.5-2 \sqrt{3}$. 
From $1 \leqslant a \leqslant b \leqslant 2$, we know
$$
\frac{3}{a}+b \leqslant \frac{3}{1}+2=5 \text {. }
$$

When $a=1, b=2$, the maximum value $M=5$ is obtained.
$$
\text { Also, } \frac{3}{a}+b \geqslant \frac{3}{a}+a \geqslant 2 \sqrt{\frac{3}{a} \cdot a}=2 \sqrt{3} \text {, when } a=b
$$
$=\sqrt{3}$, the minimum value $m=2 \sqrt{3}$ is obtained.
Therefore, $M-m=5-2 \sqrt{3}$.