On Tue, 5 Oct 2004, Kazuho Oku wrote:

>From: "Christian Smith" <[EMAIL PROTECTED]>
>
>The apache module I am writing is an access controller.  It queries the
>SQLite database and send different contents to clients depending on their IP
>addresses / cookies.


So it's a simple table lookup based on a multi-part key (ip,cookie)?


>
>When the apache module was configured to issue SQLite queries, the
>performance decreased for 45% (it took 72.9 seconds, compared to 50.3 secs
>when the module was configured not to issue any queries).
># test details are shown below
>
>> There is going to be some performance penalty, but if it's only 1% of your
>> request time, you'll have complicated your design for very little
>> performance gain.
>(snip)
>> AFAIK, flock() is a kernel operation, and seek() and read() should not
>> touch the disk if the data blocks required are already cached, and so all
>> should be relatively cheap operations (against disk IO and network
>> latencies.)
>
>I also tried using on-memory database of SQLite.  When doing so, the
>decrease was 28% (64.2 seconds).  This means that the other 27% decrease is
>caused by I/O operations of SQLite.
>
>My target is to minimize the performance penalty to less than 10%.  So it
>seems I have to cache data by myself (to avoid overhead like compilation of
>SQL statement, etc.)    :-(


You can precompile the SQL statement and execute it many times, that
should give a speed boost.

One of the upcoming enhancements (possibly) in SQLite 3 is a persistent
page cache between transactions, which should increase performance
somewhat when there's been no updates.


>
>
>
>Benchmark Information:
>
>Test Platform:
>
 [snip]
>
>Total time for handing 5000 HTTP requests * 5 times:
>
>with SQLite queries: 72.943 seconds
>wo. SQLite queries: 50.299 seconds
>with SQLite queries to on-memory database: 64.200 seconds
>
>The test was performed from a different server connected by fast ethernet.
>For the test apachebench 1.3d was used.  The options supplied to apachebench
>were:
>
>  % ab -k -n 5000 -c 20 http://192.168.10.221:82/
>
>The content sent was the default root document of apache2.


Note, while the figures above indeed do indicate some significant slowdown
using SQLite, is the above test really representitive? On the internet,
you'll have much higher latencies. Delivering a non-static page, instead
of the static root now, will also increase the benchmark time. Factor in
those, and you'll come much closer to your target performance limit.

Remember, your fastest time is 100 hits/second (or is that 500
hits/second?) For an internet, or even intranet site, that's a lot.

Christian


-- 
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

Reply via email to