Observing Your App and
                       Everything Else It Runs On Using
                       DTrace
             ...
goal




                Learn how to Dynamically observe your
                    application and its environment.




  ...
your app...


                             Application Logic
                                                             ...
on the menu today

                            Our Setup
                                  Drupal 6.12


                 ...
one small easy step


       the AMP stack
       To build, install, integrate, performance tune and deploy
         the a...
one slide on Drupal




                                    2009 CommunityOne Conference: EAST | developers.sun.com/events...
questions questions questions

                                              How much time am I
                          ...
the big game hunt

                                                                        “M
                            ...
the vicious cycle




                            Restart
            Stop App                                          Ad...
oh please



            Please let me
            observe a live
            system.




                             200...
dynamic tracing



                          Application Logic
                        Frameworks                         ...
dynamic tracing



                          Application Logic
               -> contentAreaClick
                    -> g...
You can do it with...




                         DTrace




                                2009 CommunityOne Conference...
poll




                 Have you heard about it

            Have you used it

     Have you written d-scripts




     ...
The D - Language

                               Basics
                                 of
                       Dynamic...
instrumentation format

                                           d-script
      probe
           provider    :   module ...
command line version

                              dtrace command line




                       # dtrace -n probe’/pred...
demo




                       2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone   18



Sunday...
aggregation

             dtrace -P syscall
              => mmap             mmap
               5 <= mmap               ...
dtrace aggregates - demo




                                        2009 CommunityOne Conference: EAST | developers.sun.c...
the pid provider


                                    •   Dynamically create probes in
        provider: pid$<processId> ...
demo




                       2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone   22



Sunday...
probing MySQL using Pid


    provider: pid$<mysql-pid>
    module: not-used
    probe:*dispatch_command*    #!/usr/sbin/d...
dtrace and mysql - demo




                                       2009 CommunityOne Conference: EAST | developers.sun.com...
php provider
                                  New and improved in OpenSolaris 2009.06
                                   ...
dtrace and php - demo




                                     2009 CommunityOne Conference: EAST | developers.sun.com/eve...
Apache provider


                                             received-request
      provider: apache$<pid>
      module:...
gotcha




                        2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone   28



Sun...
dtrace and the webstack




                                       2009 CommunityOne Conference: EAST | developers.sun.com...
Observing the entire stack
       More details on the scripts we saw earlier...

       what are the hot modules in Drupal...
Give me more!
       DTrace landing page:
            http://www.opensolaris.org/os/community/dtrace

       DTrace Toolki...
Social
       My Blog:
         http://blogs.sun.com/angelo


       Twitter:
         rajadurai

       DTrace hands on l...
Observing Your App and
                       Everything Else It Runs On Using
                       DTrace
             ...
DTrace and JavaScript




                                     2009 CommunityOne Conference: EAST | developers.sun.com/eve...
Observing javascript using the javascript provider

       Enter script details




                               2009 Co...
implementation




                              2009 CommunityOne Conference: EAST | developers.sun.com/events/communityo...
Upcoming SlideShare
Loading in...5
×

DTrace and Drupal

3,172

Published on

Understand the need for dynamic tracing. See how you can use a tool like dtrace to observe a live running application. Deep dive into drupal using DTrace

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

No Downloads
Views
Total Views
3,172
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
36
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

DTrace and Drupal

  1. 1. Observing Your App and Everything Else It Runs On Using DTrace session code S308357 Angelo Rajadurai Sr. Technology Evangelist – Sun Microsystems Inc. Sunday, May 31, 2009
  2. 2. goal Learn how to Dynamically observe your application and its environment. 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone Sunday, May 31, 2009
  3. 3. your app... Application Logic ruby Frameworks python Presentation php C++ C JSP/Javascript/Ajax/JavaFX perl Container Glassfish/J2EE shell java Database Apps run Native in VM Apps MySQL/Oracle/Postgres Operating System Solaris/Linux/OS X/Windows 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 3 Sunday, May 31, 2009
  4. 4. on the menu today Our Setup Drupal 6.12 Apache 2.2 PHP - Zend 5.2 MySQL 5.1.30 Amp Stack OpenSolaris 2009.06 4 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone Sunday, May 31, 2009
  5. 5. one small easy step the AMP stack To build, install, integrate, performance tune and deploy the amp stack on opensolaris... # pkg install amp-dev 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 5 Sunday, May 31, 2009
  6. 6. one slide on Drupal 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 6 Sunday, May 31, 2009
  7. 7. questions questions questions How much time am I spending in Apache/ How much of my load is MySQL/PHP? from anonymous users What are the Drupal modules that take up the most time? What type of database load is caused by anonymous users What are the most expensive hooks in a given Drupal module? 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 7 Sunday, May 31, 2009
  8. 8. the big game hunt “M ay m in” Da be ta d r: e a th bas pe as lo b e w i m Ad e ve ata ll idd mi De d kn le n: o w wa e th ” re k gu as ys “I’d “I : do S n’t ysa e rt in” xp adm De kno dmi E e ys ve w! n ar e S lop A e r sk d lew th ” th id sk e M a s et “L 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 8 Sunday, May 31, 2009
  9. 9. the vicious cycle Restart Stop App Add Code Compile w/ flags Prebuilt Instruments Custom Instruments Instrument Validate Run in production Process Collect info 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 9 Sunday, May 31, 2009
  10. 10. oh please Please let me observe a live system. 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 10 Sunday, May 31, 2009
  11. 11. dynamic tracing Application Logic Frameworks c Presentation c++ 12::SELECT id, name, symbol, conversion_rate FROM currencies WHERE JSP/Javascript/Ajax status = 'Active' and deleted = 0 12::SELECT category, name, value FROM config ph pytho 12::SELECT id FROM outbound_email WHERE type = 'system' rub Container Glassfish/Tomcat perl Database shell Native Operating System Solaris/Linux/OS X/ 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 11 Sunday, May 31, 2009
  12. 12. dynamic tracing Application Logic -> contentAreaClick -> getPreventDefault c <- getPreventDefault Frameworks <- contentAreaClick Presentation c++ JSP/Javascript/Ajax ph pytho rub Container Glassfish/Tomcat perl Database shell Native Operating System Solaris/Linux/OS X/ 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 12 Sunday, May 31, 2009
  13. 13. You can do it with... DTrace 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 13 Sunday, May 31, 2009
  14. 14. poll Have you heard about it Have you used it Have you written d-scripts 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 14 Sunday, May 31, 2009
  15. 15. The D - Language Basics of Dynamic Instrumentation 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 15 Sunday, May 31, 2009
  16. 16. instrumentation format d-script probe provider : module : probe : name where / predicate / when { actions do what } 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 16 Sunday, May 31, 2009
  17. 17. command line version dtrace command line # dtrace -n probe’/predicate/{action}’ 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 17 Sunday, May 31, 2009
  18. 18. demo 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 18 Sunday, May 31, 2009
  19. 19. aggregation dtrace -P syscall => mmap mmap 5 <= mmap mmap 5 => munmap munmap 5 <= munmap munmap 5 => setcontext setcontext 5 <= setcontext setcontext 5 => getrlimit getrlimit 5 <= getrlimit getrlimit 5 => getpid getpid 5 <= getpid getpid 5 => setcontext setcontext 5 <= setcontext setcontext 5 => sysi86 sysi86 5 <= sysi86 sysi86 5 => brk brk 5 <= brk brk 5 => brk brk 5 <= brk brk 5 => xstat xstat 5 <= xstat xstat 5 => resolvepath resolvepath 5 <= resolvepath resolvepath 5 => open open 5 <= open 5 => mmap open mmap rexit 1 5 <= mmap 5 => mmap mmap mmap fcntl 2 fsat 2 5 <= mmap mmap 5 => mmap mmap 5 <= mmap mmap 5 => mmap 5 <= mmap mmap mmap getpid 2 5 => munmap 5 <= munmap munmap munmap getrlimit 2 sysi86 2 5 => memcntl memcntl 5 <= memcntl memcntl 5 => close close 5 <= close 5 => xstat close xstat write 2 fstat64 4 5 <= xstat xstat 5 => resolvepath resolvepath 5 <= resolvepath resolvepath 5 => open 5 <= open open open getdents64 4 5 => mmap 5 <= mmap mmap mmap memcntl 4 open 4 5 => mmap mmap 5 <= mmap mmap 5 => mmap mmap 5 <= mmap 5 => mmap mmap mmap resolvepath 4 5 <= mmap 5 => mmap 5 <= mmap mmap mmap mmap setcontext 4 5 => munmap 5 <= munmap munmap munmap xstat 4 5 => memcntl 5 <= memcntl 5 => close memcntl memcntl close ioctl 6 5 <= close 5 => munmap close munmap brk 8 5 <= munmap 5 => ioctl ioctl munmap munmap 8 close 10 5 <= ioctl ioctl 5 => ioctl ioctl 5 <= ioctl ioctl 5 => brk 5 <= brk 5 => brk brk brk brk mmap 20 5 <= brk brk 5 => fsat fsat 5 <= fsat fsat 5 => fcntl fcntl 5 <= fcntl fcntl 5 => fstat64 fstat64 5 <= fstat64 fstat64 5 => getdents64 getdents64 5 <= getdents64 getdents64 5 => getdents64 getdents64 dtrace -P syscall’{@=count(probefunc)}’ 5 <= getdents64 getdents64 5 => close close 5 <= close close 5 => ioctl ioctl 5 <= ioctl ioctl 5 => fstat64 fstat64 5 <= fstat64 fstat64 5 => write write 5 <= write write 5 => close close 5 <= close close 5 => close close 5 <= close close 5 => rexit rexit 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 19 Sunday, May 31, 2009
  20. 20. dtrace aggregates - demo 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 20 Sunday, May 31, 2009
  21. 21. the pid provider • Dynamically create probes in provider: pid$<processId> live running applications. module: name of library probe: function name • No extra work needed from name: entry application developer return offset • Available without any compile or runtime flags • Can be created on optimized Pr binaries as well Pi id ov • Probes created at function d er boundaries and offset 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 21 Sunday, May 31, 2009
  22. 22. demo 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 22 Sunday, May 31, 2009
  23. 23. probing MySQL using Pid provider: pid$<mysql-pid> module: not-used probe:*dispatch_command* #!/usr/sbin/dtrace -qs name: entry arg2 - SQL command pid$1::*dispatch_command*:entry { printf("%sn",copyinstr(arg2,arg3)); } M ue Q yS ri Q es L 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 23 Sunday, May 31, 2009
  24. 24. dtrace and mysql - demo 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 24 Sunday, May 31, 2009
  25. 25. php provider New and improved in OpenSolaris 2009.06 compile-file-entry/-return function-entry/-return provider: php$<pid> module: not-used execution-entry/-return probe: not-used exception-thrown/-catched name: <see detail -> error request-startup/-shutdown Ap ov Pr Older releases ac id he er function-entry/-return 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 25 Sunday, May 31, 2009
  26. 26. dtrace and php - demo 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 26 Sunday, May 31, 2009
  27. 27. Apache provider received-request provider: apache$<pid> module: not-used log-request probe: not-used name: <see detail -> create-child accept-connection check-user-credentials check-access Ap ov Pr check-authorization ac id he er 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 27 Sunday, May 31, 2009
  28. 28. gotcha 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 28 Sunday, May 31, 2009
  29. 29. dtrace and the webstack 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 29 Sunday, May 31, 2009
  30. 30. Observing the entire stack More details on the scripts we saw earlier... what are the hot modules in Drupal? what are the hot hooks in Drupal? how much of my Drupal load is from anonymous users how much time am I spending in Apache/MySQL/PHP? what are the SQL statements that are executed by anon users 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 30 Sunday, May 31, 2009
  31. 31. Give me more! DTrace landing page: http://www.opensolaris.org/os/community/dtrace DTrace Toolkit: In OpenSolaris - /opt/DTT Solaris download - http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/ DTrace Bigadmin page: http://www.sun.com/bigadmin/content/dtrace/ Lots and lots of info on the web - Google “dtrace” 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 31 Sunday, May 31, 2009
  32. 32. Social My Blog: http://blogs.sun.com/angelo Twitter: rajadurai DTrace hands on lab http://developers.sun.com/learning/javaoneonline/j1lab.jsp? lab=LAB-9400&yr=2008&track=1 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 32 Sunday, May 31, 2009
  33. 33. Observing Your App and Everything Else It Runs On Using DTrace session code S308357 Angelo Rajadurai angelo.rajadurai@sun.com Sunday, May 31, 2009
  34. 34. DTrace and JavaScript 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 34 Sunday, May 31, 2009
  35. 35. Observing javascript using the javascript provider Enter script details 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 35 Sunday, May 31, 2009
  36. 36. implementation 2009 CommunityOne Conference: EAST | developers.sun.com/events/communityone 36 Sunday, May 31, 2009
  1. A particular slide catching your eye?

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

×