Recently I've noticed the mysql server going very slow at times. At such times i've run show full processlist and there's been one or two processes with a status sleep and time being anything up to about 40 seconds.
What are theses proceses? Are they read/write processes waiting for their turn? Is it possible that further queries coming are just stuck in a non-moving queue?
btw I'm connecting from php using mysql_connect (I think that's non-persistent)
I believe sleeping processes are normal. I'm not completely sure about MySQL, but I know that in Sybase, a sleeping process is just an open connection which is waiting to receive a command to execute. When a thread is running it will say something along the lines of "running SELECT" or "running UPDATE."
As long as you don't have a huge number of unused connections open which for some reason not accepting any queries (if that's even possible), I'd say your problem lies elsewhere.
Also, mysql_connect() automatically closes connections at the end of the script (mysql_close() isn't necessary, but is good practice.) mysql_pconnect() will open/re-establish a persistent connection.