You are viewing a plain text version of this content. The canonical link for it is here.
Posted to olio-dev@incubator.apache.org by Vasileios Kontorinis <bk...@gmail.com> on 2010/06/09 22:55:30 UTC

Getting relative time spend on db, filestore and web-server

Akara/Shanti/olio-dev hi,
     Here is what I am currently trying to do. I need a relative estimate of
how much time is spend on the db queries, the requests from the filestore
(NFS rpcs) and the web-server processing the user requests. Ideally, this
can be a great feature for Olio. Imagine having to debug a performance issue
and olio providing an average breakdown of response time to web/db/filestore
time. It would immediately tell you where you should start looking for the
problem. Additionally would immediately tell you how much you can improve
you performance by upgrading your storage hardware, optimizing your queries,
adding more resources to your web-server etc.
I understand this is pretty hard to implement, because db queries, filestore
accesses  can be done by multiple files and proper accounting should be
supported by Faban (send back to the users/master).
Some thoughts:
- *Where to start: *It appears that the php code on the server side is the
only place where this can be done.
- *Storage:* This makes sense only per user, so the session is probably a
logical place to store this info.
- *Organization*: Since response time is measured per operation with Faban,
this also needs to be per operation.
- *Timestamps:* I believe from php I could use getMicroTime() before I start
a query, call it again after it's done and get a diff.
- *Overhead:* Since I will have to log the result in the sessions for every
operation this will likely be a performance killer. Sampling can be applied
to do logging every 100 requests or so.

Insights, ideas are most welcome.

Thanks
-------------------------------------------------------------------
Kontorinis Vasileios
Phd student, University of California San Diego
http://cseweb.ucsd.edu/~vkontori/
bkontorinis@gmail.com
-------------------------------------------------------------------

Re: Getting relative time spend on db, filestore and web-server

Posted by Shanti Subramanyam <sh...@gmail.com>.
As you correctly surmise, this is a non-trivial task. There is a whole class
of tools called "APM" (Application Performance Monitoring) which sell for as
much as $100K that do this.
However, if you were running on Solaris, you could use 'dtrace' to do this.
All you need to know are the C entry points in the various tiers. You may
want to see whether SystemTap can help.
If you were running the Java version, you could also do this with a little
bit of effort using JVMTI or BTrace.
Heh - this could be a research paper on it's own !

In general, it is much better to do this using external frameworks than
building out such complex functionality within Olio.

Shanti

On Wed, Jun 9, 2010 at 3:55 PM, Vasileios Kontorinis
<bk...@gmail.com>wrote:

> Akara/Shanti/olio-dev hi,
>      Here is what I am currently trying to do. I need a relative estimate
> of how much time is spend on the db queries, the requests from the filestore
> (NFS rpcs) and the web-server processing the user requests. Ideally, this
> can be a great feature for Olio. Imagine having to debug a performance issue
> and olio providing an average breakdown of response time to web/db/filestore
> time. It would immediately tell you where you should start looking for the
> problem. Additionally would immediately tell you how much you can improve
> you performance by upgrading your storage hardware, optimizing your queries,
> adding more resources to your web-server etc.
> I understand this is pretty hard to implement, because db queries,
> filestore accesses  can be done by multiple files and proper accounting
> should be supported by Faban (send back to the users/master).
> Some thoughts:
> - *Where to start: *It appears that the php code on the server side is the
> only place where this can be done.
> - *Storage:* This makes sense only per user, so the session is probably a
> logical place to store this info.
> - *Organization*: Since response time is measured per operation with
> Faban, this also needs to be per operation.
> - *Timestamps:* I believe from php I could use getMicroTime() before I
> start a query, call it again after it's done and get a diff.
> - *Overhead:* Since I will have to log the result in the sessions for
> every operation this will likely be a performance killer. Sampling can be
> applied to do logging every 100 requests or so.
>
> Insights, ideas are most welcome.
>
> Thanks
> -------------------------------------------------------------------
> Kontorinis Vasileios
> Phd student, University of California San Diego
> http://cseweb.ucsd.edu/~vkontori/ <http://cseweb.ucsd.edu/%7Evkontori/>
> bkontorinis@gmail.com
> -------------------------------------------------------------------
>

Re: Getting relative time spend on db, filestore and web-server

Posted by Richard Smith <ri...@oracle.com>.
Vasileios Kontorinis wrote:
... Imagine having to debug a performance issue
> and olio providing an average breakdown of response time to web/db/filestore
> time. It would immediately tell you where you should start looking for the
> problem.

Actually I don't have to imagine it, having done this in the past!
For the PHP code itself, I have used microtime() to instrument
bits of the code, then used a convenience function that I put
in config.php to log it.

$t0 = microtime(true);
...code...
$t1 = microtime(true);
timing("APRS01", $t0, $t1);

For db and filestore times I used a couple of different approaches.
Since I was using Solaris, I could use DTrace to put probes on
key functions in the PHP runtime that requests to db and filestore
pass through. Apart from the webserver-specific probe points
[I was using Sun Java System Web Server] for measuring the
handling of web requests and the handing off to PHP, I used
zim_PDO_* for db (MySQL), zif_memcache_* for memcached,
zif_readfile for filestore.

Looking at it in hindsight, it seems that list doesn't capture
the cost of writing images to the filestore. I think that's
one area where I explicitly instrumented the PHP code instead.
Session files themselves had to be distributed over a directory
hierarchy to avoid lock contention on a single directory.

Since the webserver was multithreaded, I used thread id (tid), as
a filter to control how much data I collected. All users should
have been identical profiles, so I collected data from a subset
of the threads servicing incoming threads. [I had about
210 threads in the pool and traced 10 of them.]

If you didn't have DTrace, then it should still be possible to
write an interpose library to get the data. That does leave a
challenge as to what to do with the data once collected.

It does seem desirable to me to have a more scalable, integrated,
logging mechanism available inside the webserver environment to
which performance data can be added to augment URL, response time,
etc.

FWIW I also used DTrace at the db backend to measure database
activity for individual requests. It would be helpful if there
was some sort of tag or transaction identifier that followed
a request around the system, so when data is collected it can
be tagged. This would facilitate combining data from multiple
sources in a post-experiment phase.


-- 
============================================================================
     ,-_|\   Richard Smith PAE
    /     \  Oracle                             Phone : +61 3 9869 6200
richard.r.smith@oracle.com                    Direct : +61 3 9869 6224
    \_,-._/  476 St Kilda Road                    Fax : +61 3 9869 6290
         v   Melbourne Vic 3004 Australia
===========================================================================