I've written a CGI script to query information from our TeamCity server via the REST API and have discovered that the performance is sporadic. While the performance is normally OKish (around 0.4 to 0.6 seconds to do 21 queries) it often goes way slower than this, taking many seconds to do the same number or queries. So I started running "top" on the server to see what was happening and while the machine is mostly idle every so often the java process running the TeamCity server starts chewing up loads of CPU for a while before returning to the normal low level of CPU activity. It looks like any REST query during these spikes gets stalled, so I guess there's some kind of lock in effect blocking them. How can I go about working out what's causing these spike? And are there any settings I can change to prevent such spikes blocking REST queries?