Dynamic Tracing your AMP site Sriram Natarajan Engineer Sun Microsystems Inc
What is Dtrace ? <ul><li>Old school performance analysis </li><ul><ul><li>Collect data as required.
Analyze data looking for bottlenecks, trends and correlations.
Speculate on remedies
Evaluate and repeat the process </li></ul></ul><li>Does not replace any of the existing tools like vmstat, mpstat, prstat,...
Largely new functionality to ask questions. </li></ul>
How does it work ? <ul><li>Ability to instrument binary code on the fly
Zero probe effect when Dtrace is not running.
Does a fast trap into Dtrace probe to minimize performance impact. </li></ul>
A simple Dtrace script #!/usr/sbin/dtrace -qs syscall:::entry  {  @num[probefunc] = count()  }
Dtrace format ●   provider:module:function:name ●  -P provider ●  -m module ●  -f function ●  -n name ●  -s script ●  -p p...
How to write a Dtrace script <ul><li>Sample Dtrace scripts.  </li><ul><ul><li>/usr/demo/dtrace (Solaris 10/OpenSolaris) </...
http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/ </li></ul></ul></ul><li>Customize and built upon these sampl...
MySQL sample Dtrace scripts are available at </li><ul><ul><li>http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-mysqld-ref...
Dtrace for AMP stack <ul><li>Apache Dtrace probes are made possible by Apache Dtrace extension
MySQL / PHP Dtrace probes are enabled within engine
Fired when execution flow reaches probe location.
Upcoming SlideShare
Loading in...5
×

Dynamic Tracing of your AMP web site

2,340

Published on

Brief introduction to DTrace technologies within OpenSolaris/Solaris 10 and DTrace probes within Apache, PHP and MySQL can provide end to end dynamic tracing of your Drupal based web site..

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,340
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Dynamic Tracing of your AMP web site

  1. 1. Dynamic Tracing your AMP site Sriram Natarajan Engineer Sun Microsystems Inc
  2. 2. What is Dtrace ? <ul><li>Old school performance analysis </li><ul><ul><li>Collect data as required.
  3. 3. Analyze data looking for bottlenecks, trends and correlations.
  4. 4. Speculate on remedies
  5. 5. Evaluate and repeat the process </li></ul></ul><li>Does not replace any of the existing tools like vmstat, mpstat, prstat, sar etc..
  6. 6. Largely new functionality to ask questions. </li></ul>
  7. 7. How does it work ? <ul><li>Ability to instrument binary code on the fly
  8. 8. Zero probe effect when Dtrace is not running.
  9. 9. Does a fast trap into Dtrace probe to minimize performance impact. </li></ul>
  10. 10. A simple Dtrace script #!/usr/sbin/dtrace -qs syscall:::entry { @num[probefunc] = count() }
  11. 11. Dtrace format ● provider:module:function:name ● -P provider ● -m module ● -f function ● -n name ● -s script ● -p pid ● -c run command ● -l list ● -v verbose
  12. 12. How to write a Dtrace script <ul><li>Sample Dtrace scripts. </li><ul><ul><li>/usr/demo/dtrace (Solaris 10/OpenSolaris) </li></ul></ul><li>Dtracetoolkit includes task specific Dtrace scripts for OpenSolaris. </li><ul><ul><ul><li>/opt/DTT (OpenSolaris)
  13. 13. http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/ </li></ul></ul></ul><li>Customize and built upon these sample scripts.
  14. 14. MySQL sample Dtrace scripts are available at </li><ul><ul><li>http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-mysqld-ref.html </li></ul></ul></ul>
  15. 15. Dtrace for AMP stack <ul><li>Apache Dtrace probes are made possible by Apache Dtrace extension
  16. 16. MySQL / PHP Dtrace probes are enabled within engine
  17. 17. Fired when execution flow reaches probe location.
  18. 18. No overhead for inactive probes.
  19. 19. Provide hard to get under the hood information in a simple way.
  20. 20. Some performance hit depending on number of probes fired </li></ul>
  21. 21. Sample MySQL D Script #!/usr/sbin/dtrace -qs dtrace:::BEGIN { printf(&quot;%-40s %2s %-9s &quot;, &quot;Query&quot;, &quot;QC&quot;, &quot;Time(ms)&quot;); } mysql*:::query-start { self->query = copyinstr(arg0); self->querystart = timestamp; self->qc = 0; } mysql*:::query-cache-hit { self->qc = 1; } mysql*:::query-cache-miss { self->qc = 0; } mysql*:::query-done { printf(&quot;%-40s %-2s %-9d &quot;,self->query,(self->qc ? &quot;Y&quot; : &quot;N&quot;), (timestamp - self->querystart) / 1000000); }
  22. 22. Sample MySQL D Script Output select * from t1 order by i limit 10 N 1072 set global query_cache_size=262144 N 0 select * from t1 order by i limit 10 N 781 select * from t1 order by i limit 10 Y 0 select * from t1 order by i limit 30 Y 0 select * from t1 order by i limit 10 Y 0 select * from t1 order by i limit 10 Y 0
  23. 23. MySQL Dtrace probes connection-start(id, user, hostname) connection-done(status, id) command-start(id, command_id) command-end(status) query-start(query, id, db, user, host) query-done(status) query-parse-start(query) query-parse-done(status) query-cache-hit(query, row) query-cache-miss(query) query-exec-start(query, id, db, host, exec_type) query-exec-done(status) insert/update/delete-row-start(db, table, status) insert/update/delete-row-done(db, table, status) select/insert/update/multi-update-start(query, status, rows, rowsmatched, rowschanged) select/insert/update/multi-update-done(query, status, rows, rowsmatched, rowschanged)
  24. 24. Sample PHP D Script php*:::compile-file-entry /arg0 != NULL/ { self->compile_file = copyinstr(arg0); self->compile_start_time = timestamp; } php*:::compile-file-return /self->compile_file == copyinstr(arg0)/ { self->compile_elapsed = ((timestamp - self->compile_start_time) / 1000000); @compile_time[self->compile_file] = quantize(self->compile_elapsed); self->compile_file = 0; self->compile_file_translated = 0; self->compile_start_time = 0; } tick-60s { printf(&quot; Exclusive compile elapsed times, &quot;); printa(&quot; %s, %@d &quot;, @compile_time); }
  25. 25. PHP Dtrace probes request-startup(request-file, request-uri, request-method) request-end(request-file, request-uri, request-method) compile-file-entry(compile-file, compile-file-translated) compile-file-return(compile-file, compile-file-translated) function-entry(function-name, request-file, lineno, classname, scope) function-end(function-name, request-file, lineno, classname, scope) execute-entry(request-file, lineno) execute-end(request-file, lineno) error(errormsg, request-file, lineno) execption-thrown(classname) exception-catched(classname)
  26. 26. Ongoing PHP Dtrace work <ul><li>Probes now integrated within PHP engine – thanks to Wez Furlong and David Soria Parra
  27. 27. More probes planned at these places: </li><ul><ul><li>To track GC events.
  28. 28. To track Object create / destroy life cycle.
  29. 29. To track Session life cycle. </li></ul></ul><li>Release sample Dtrace scripts to webstack community. </li></ul>
  30. 30. Apache Dtrace Probes accept_connection(uint*) log_request(uint*, char*, char*) receive_request (uint*) create_child() check_user_credentials(uint*) check_access(uint*) check_authorization(uint*)
  31. 31. How to try it out ? <ul><li>AMP stack within OpenSolaris 2009.06 includes Dtrace probes. </li><ul><ul><li>Dtrace probes are integrated within Apache, PHP and MySQL source repository. </li></ul></ul><li>Available for Solaris 10 as Sun Glassfish Web Stack. </li><ul><ul><li>http://www.sun.com/webstack </li></ul><li>Compile yourself </li><ul><li>MySQL probes are integrated within MySQL 5.4
  32. 32. Apache Dtrace probes are available at http://prefetch.net
  33. 33. PHP Dtrace probes are integrated within PHP 6.x source tree.
  34. 34. Ruby Dtrace probes are integrated within Ruby source. </li></ul></ul></ul>
  35. 35. To learn more on DTrace... <ul><li>Dtrace Toolkit (sample scripts) </li><ul><ul><li>http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/ </li></ul></ul><li>Dtrace documentation </li><ul><ul><li>http://www.sun.com/bigadmin/content/dtrace/
  36. 36. https://www.opensolaris.org/os/community/dtrace/
  37. 37. http://opensolaris.org/os/community/performance/ </li></ul></ul><li>Apache Dtrace sample scripts </li><ul><ul><li>http://prefect.net </li></ul></ul><li>MySQL Dtrace probe documentation: </li><ul><ul><li>http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-mysqld-ref.html </li></ul></ul></ul>
  38. 38. To learn more on Web Stack... <ul><li>Open Solaris Web Stack Project Home </li><ul><ul><li>http://www.opensolaris.org/os/project/webstack </li></ul></ul><li>Apache, Dtrace and MySQL probes are part of Web Stack (OpenSolaris, Solaris 10)
  39. 39. PHP Dtrace probes are now documented at </li><ul><ul><li>http://blogs.sun.com/natarajan/entry/new_dtrace_probes_within_php </li></ul></ul><li>Sun Web Stack documentation </li><ul><ul><li>http://wikis.sun.com/display/webstack </li></ul></ul></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×