On 21 Jan 2016, at 9:44am, Daniel Polski <daniel at agelektronik.se> wrote:

> The Webserver/PHP can process up to 16 requests simultanuously and will share 
> one database connection among all instances.
> The process for each request is:
> 
> * Use PHP's PDO extension to open a persistent (shared among all instances) 
> connection to the database
>  -> In the background PHP will only open the database once and then use this 
> connection forever

You have a persistent PHP process on the server ?  How are you limiting this to 
16 simultaneous connections ?  I'm not saying any of your procedure is wrong, 
I'm just curious about how it is done under (presumably) Apache.

> PRAGMA journal_mode = WAL;

Unlike the other two PRAGMAs which do their job you don't need this line.  Once 
the database is in WAL mode that fact is saved in the file.  It won't change 
unless you intentionally switch it to something else.

> * If a query fails, due to a busy timeout or locked database (what may occur 
> in situations of high system load) the query is retried 10 times, with a 
> 100ms sleep between the retries

This is less efficient than PHP/SQLite's own busy processing.  Figure out what 
you want the total retry to be (probably ten seconds or so) and use that figure 
for the timeout setting:

PRAGMA busy_timeout = 10 * 1000;

then just take the first _LOCKED or _BUSY as a failure.

> * At the end of a request, the database is left open (i.e. no disconnect is 
> done) in order to maintain the persistent database connection

I am inferring that your queries are executed in one command i.e. exec() or 
execute() rather than _prepare,_step,_finalize.

Simon.

Reply via email to