Dynamic Tracing of your AMP web site

  • 2,253 views
Uploaded 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..

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..

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,253
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
22
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Dynamic Tracing your AMP site Sriram Natarajan Engineer Sun Microsystems Inc
  • 2. What is Dtrace ?
    • Old school performance analysis
        • Collect data as required.
        • 3. Analyze data looking for bottlenecks, trends and correlations.
        • 4. Speculate on remedies
        • 5. Evaluate and repeat the process
    • Does not replace any of the existing tools like vmstat, mpstat, prstat, sar etc..
    • 6. Largely new functionality to ask questions.
  • 7. How does it work ?
    • Ability to instrument binary code on the fly
    • 8. Zero probe effect when Dtrace is not running.
    • 9. Does a fast trap into Dtrace probe to minimize performance impact.
  • 10. A simple Dtrace script #!/usr/sbin/dtrace -qs syscall:::entry { @num[probefunc] = count() }
  • 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. How to write a Dtrace script
    • Sample Dtrace scripts.
        • /usr/demo/dtrace (Solaris 10/OpenSolaris)
    • Dtracetoolkit includes task specific Dtrace scripts for OpenSolaris.
          • /opt/DTT (OpenSolaris)
          • 13. http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/
    • Customize and built upon these sample scripts.
    • 14. MySQL sample Dtrace scripts are available at
        • http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-mysqld-ref.html
  • 15. Dtrace for AMP stack
    • Apache Dtrace probes are made possible by Apache Dtrace extension
    • 16. MySQL / PHP Dtrace probes are enabled within engine
    • 17. Fired when execution flow reaches probe location.
    • 18. No overhead for inactive probes.
    • 19. Provide hard to get under the hood information in a simple way.
    • 20. Some performance hit depending on number of probes fired
  • 21. Sample MySQL D Script #!/usr/sbin/dtrace -qs dtrace:::BEGIN { printf("%-40s %2s %-9s ", "Query", "QC", "Time(ms)"); } 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("%-40s %-2s %-9d ",self->query,(self->qc ? "Y" : "N"), (timestamp - self->querystart) / 1000000); }
  • 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. 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. 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(" Exclusive compile elapsed times, "); printa(" %s, %@d ", @compile_time); }
  • 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. Ongoing PHP Dtrace work
    • Probes now integrated within PHP engine – thanks to Wez Furlong and David Soria Parra
    • 27. More probes planned at these places:
        • To track GC events.
        • 28. To track Object create / destroy life cycle.
        • 29. To track Session life cycle.
    • Release sample Dtrace scripts to webstack community.
  • 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. How to try it out ?
    • AMP stack within OpenSolaris 2009.06 includes Dtrace probes.
        • Dtrace probes are integrated within Apache, PHP and MySQL source repository.
    • Available for Solaris 10 as Sun Glassfish Web Stack.
        • http://www.sun.com/webstack
      • Compile yourself
        • MySQL probes are integrated within MySQL 5.4
        • 32. Apache Dtrace probes are available at http://prefetch.net
        • 33. PHP Dtrace probes are integrated within PHP 6.x source tree.
        • 34. Ruby Dtrace probes are integrated within Ruby source.
  • 35. To learn more on DTrace...
    • Dtrace Toolkit (sample scripts)
        • http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/
    • Dtrace documentation
        • http://www.sun.com/bigadmin/content/dtrace/
        • 36. https://www.opensolaris.org/os/community/dtrace/
        • 37. http://opensolaris.org/os/community/performance/
    • Apache Dtrace sample scripts
        • http://prefect.net
    • MySQL Dtrace probe documentation:
        • http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-mysqld-ref.html
  • 38. To learn more on Web Stack...
    • Open Solaris Web Stack Project Home
        • http://www.opensolaris.org/os/project/webstack
    • Apache, Dtrace and MySQL probes are part of Web Stack (OpenSolaris, Solaris 10)
    • 39. PHP Dtrace probes are now documented at
        • http://blogs.sun.com/natarajan/entry/new_dtrace_probes_within_php
    • Sun Web Stack documentation
        • http://wikis.sun.com/display/webstack