I'm developing web application, that communicates with bitcoind through JSON rpc api. Sometimes sendtoaddress call takes 30+ seconds to perform which is too long, as to me. Bitcoind version 100100 is installed on 8Gb RAM VPS. Any recommendations how to debug this? I need to find out why some requests are so slow. Any help will be appreciated.
30+ seconds is nothing. With sufficiently complex wallet it could take minutes to return from RPC call. With backups running in the background I've observed over 15 minutes to service complex sendmany requests.
The problem is unfixable with the current architecture.
If you really trying to develop something reliable you will have to monitor the wallet access directly through BerkeleyDB API and/or utilities. Start bitcoind with -privdb=0, create an appropriate DB_CONFIG and then you can monitor the wallet lock activity of the live bitcoind instance.