Representing a number as a sum of at most $k$ squares Fix an integer $k >0 $ and would like to know the maximum number of different ways that a number $n$ can be expressed as a sum of $k$ squares, i.e. the number of integer solutions to
$$ n = x_1^2 + x_2^2 + \dots + x_k^2$$
with $x_1 \ge x_2 \ge \dots \ge x_k$ and $x_i \ge 0$ for every $i$.
What I'd really like to know about is the asymptotics as $n \to \infty$.
I asked a number theorist once about the case $k=2$, and if I remember correctly, he said that there are numbers $n$ which can be expressed as a sum of two squares in at least $$n^{c/\log \log n}$$ different ways, for some constant $c > 0$, and this is more-or-less best possible. This is the kind of answer I am seeking for larger $k$.
Clarification:
What I mean by maximum is the following.  I want functions $f_k(x)$, as large as possible, such that there exists some sequence of integers $\{ a_i \}$ with $a_i \to \infty$,
and such that $a_i$ can be written as the sum of $k$ squares in at least $f_k(a_i)$ ways.

The leading term of the asymptotics will be $r_k(n)/k!$ where $r_k(n)$ is the unconstrained number of representations of $n$ as a sum of squares of $k$ integers. For specific $k$ such as 4 or 8 there are classical formulas as sums of arithmetic functions (proofs use modular forms). For fixed $k>4$ the leading term is on average equal to $An^b$ with $A$ and $b$ calculable from volumes of spheres, but as explained in the answer by Greg Martin, the "constant" $A$ is in fact a quasiperiodic function of $n$, the singular series (the product of p-adic densities of solutions to the equation).  
