Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: learning memcached

by punkish (Priest)
on May 21, 2011 at 02:51 UTC ( #906022=note: print w/ replies, xml ) Need Help??


in reply to Re: learning memcached
in thread learning memcached

> I think you benchmark is flawed. You say you have 20_000 random 
> entries, but you only make 2723 queries.

How did you determine that I made only 2723 queries? The benchmark shows that I made 40_000 queries for each code fragment at a rate of 2723 queries per second with the memcache process and 3846 queries per second with the straight-from-db process. Or, am I reading the results wrong?

Update: Here is another measurement, this time using timethese. The results are the same as before.

query_dbh: 24 wallclock secs ( 5.28 usr + 5.29 sys = 10.57 CPU) @ 37 +84.30/s (n=40000) query_mem: 70 wallclock secs ( 7.80 usr + 6.08 sys = 13.88 CPU) @ 28 +81.84/s (n=40000)

Whatever I am doing, it is far faster to open up the SQLite database every time and query it than it is to query the memory cached value. (I am creating a $dbh and $sth every time, and also opening a file and writing to it every time to kinda emulate a CGI process that starts afresh on every hit of the browser.



when small people start casting long shadows, it is time to go to bed


Comment on Re^2: learning memcached
Select or Download Code
Re^3: learning memcached
by Anonymous Monk on May 21, 2011 at 03:04 UTC
    Or, am I reading the results wrong?

    You're not reading the results wrong, I obviously missed the count :)

    Another (insert better word here) "flaw" , is your sql query is too simple :) The way I understand memcached, you get benefit if you cache data which is expensive to calculate

      > Another (insert better word here) "flaw" , is your sql query is too simple :) 
      > The way I understand memcached, you get benefit if you cache data which is 
      > expensive to calculate
      
      I don't see why that should matter. Sure, on a more complicated and slow query, retrieving an already calculated result will be faster. However, retrieving even the simplest of results from memory should be faster than opening a file on disk, preparing a db handle, querying, and then returning the result. At worst, it should be about the same, not 30% worse!


      when small people start casting long shadows, it is time to go to bed
        However, retrieving even the simplest of results from memory should be faster than opening a file on disk, preparing a db handle, querying, and then returning the result.

        I don't think SQLite uses sockets. memcached does use socket. That might explain the difference, maybe benchmark against a database which uses sockets.

        Or maybe opening "foo.txt" is skewing the results (unlikely, but it could happen)

        At worst, it should be about the same, not 30% worse

        I literally don't know about that, you might wish to ask the mailing list (amusing story about that).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://906022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2014-12-22 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (132 votes), past polls