Many of you may use setQueryTimeout(int timeoutValue) method of PreparedStatement object for limiting the query time. This method internally creates a Timer thread, start it whenever query starts and stop and garbage it whenever query finishes. This is a useful method and prevents suspended threads which are waiting the query results.
However, our system needs high performance and responds more than 1000 request per second by querying database. Whenever i use setQueryTimeout method for each query, the amount of responses per second decreases and CPU usage increases (thread creation, starting are very expensive and I/O bound). Therefore i want to tune my application and by the way searching a replacement for setQueryTimeout method.
Is there anyone who comes with an idea?
A guy from Turkey<br /><a href="http://blogspot.serkandemir.com" target="_blank" rel="nofollow">http://blogspot.serkandemir.com</a>
Try figuring out why you need to call setQueryTimeout() in the first place. Chances are it is a locking issue of some kind. Better transaction management and/or foreign key indexes, may vastly decrease locking such that the call is not needed.
We have a worker pool which are only responsible for database transactions. Rarely, some workers are suspended while they are querying DB. I dont know the reason behind this suspension but it happens. Thus, we need to set some waiting limits for these suspended threads. The reason for this query timeout is basically this.