Instrumenting Ruby on Rails With Traceview
Upcoming SlideShare
Loading in...5
×
 

Instrumenting Ruby on Rails With Traceview

on

  • 429 views

Installation and setup of TraceView for your Ruby application is a simple two step process that can be done in 10 minutes or less. Traceview gives a unique in-depth view into requests even as they ...

Installation and setup of TraceView for your Ruby application is a simple two step process that can be done in 10 minutes or less. Traceview gives a unique in-depth view into requests even as they cross hosts and software stacks. I run it on Gameface and PasswordPusher - it’s an essential tool in identifying problem areas, application performance bottlenecks and simply poor performing code. (Read: ActionView) To learn more about TraceView, visit http://appneta.com/traceview or read the AppNeta blog at http://appneta.com/blog

Statistics

Views

Total Views
429
Views on SlideShare
425
Embed Views
4

Actions

Likes
0
Downloads
1
Comments
0

2 Embeds 4

http://www.linkedin.com 2
https://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Instrumenting Ruby on Rails With Traceview Instrumenting Ruby on Rails With Traceview Presentation Transcript

    •    1  On  Building                :  Instrumen1ng  Ruby  with  TraceView  in  10  minutes      Peter  Lombardo  h$p://blog.gameface.in   h$p://www.appneta.com/blog  
    • I’ve  been  a  Rubyist  and  Linux  addict  for  over  a  decade,  mainly  developing  in  Ruby  and  JavaScript  (as  well  as  PHP  and  Perl).  I’m  the  creator  of  numerous  soHware  tools  and  applicaIons,  most  recently  Password  Pusher,  a  Ruby  on  Rails  applicaIon  to  communicate  passwords  over  the  web  and  Gameface,  a  social  networking  plaLorm  for  gamers  using  Rails  3.      When  I’m  not  creaIng  my  own  applicaIons,  I  help  develop  and  maintain  the  infrastructure  at  OurStage  and  manage  the  Ruby  community  for  AppNeta.  Peter  Lombardo  
    •  “Gameface  was  created  to    showcase  games,    the  people  who  play  them,  and  the  characters  they  play”    
    • TraceView  by  AppNeta  gives  a  unique  in-­‐depth  view  into  requests  even  as  they  cross  hosts  and  soKware  stacks.    Installa1on  and  setup  of  TraceView  for  your  app  is  a  simple  two  step  process  that  can  be  done  in  10  minutes  or  less.    h$p://www.appneta.com/traceview   h$p://www.appneta.com/  
    • TraceView  provides  deep  performance  monitoring  of  web  apps.    It  gives  insight  into  your  web  app  performance  such  as  this:          
    • …and  a  per  request  drill-­‐down  that  shows  you  the  niOy  griOy  detail  of  where  1me  is  spent  in  individual  requests  
    • and  even  end-­‐user  monitoring:      
    • I  run  it  on  Gameface  and  PasswordPusher  -­‐  it’s  essen1al  in  iden1fying  problem  areas,  performance  boOlenecks  and  poor  performing  code.  (Read:  Ac1onView)        Disclaimer:  I  authored  the  Ruby  instrumenta6on  for  Traceview  so  I  may  be  a  bit  biased.  …but  with  good  reason!  h$p://gameface.in   h$p://pwpush.com/  
    • Installa1on    
    • Installing  TraceView  consists  of  two  parts:      1)  installing  the  system  daemon  on  your  host,  and    2)  installing  the  Ruby  gem  in  your  applica1on  h$p://www.appneta.com/apm-­‐datasheet  
    • Why  a  system  daemon?      TraceView  uses  a  system  daemon  to  collect  instrumenta6on  from  sources  beyond  applica6on  code  such  as  host  metrics,  Apache  or  Resque.  
    • The  system  daemon  is  installed  with  two  commands  that  can  be  pasted  into  your  shell.      An  account  specific  version  of  these  commands  is  available  in  your  TraceView  dashboard  once  you  create  an  account.      (Under  SeWngs;  App  Configura1on;  Trace  New  Hosts)    
    • And  the  gem  for  your  applica1on  Gemfile  available  on  RubyGems:    h$ps://rubygems.org/gems/oboe  gem oboe !
    • Setup    
    • TraceView  func1ons  by  sampling  a  subset  of  all  requests  that  go  through  your  web  applica1on.      This  sample  rate  must  be  set  at  the  entry  point  of  requests  in  your  applica1on.    
    • This  can  be  a  load  balancer,  Apache/nginx  or  Ruby  itself.      Successive  hosts  and  soKware  stacks  that  requests  pass  through  will  act  appropriately  according  to  upstream  seWngs.!
    • Yes.      That  means  requests  can  be  traced  across  hosts,  so6ware  stacks,  even  track  internal  API  calls  via  HTTP/SOAP/REST  which  make  for  spectacular  applicaEon  insight.    …But  that’s  another  post  for  another  Eme.    
    • For  this  walkthrough  we’re  going  to  assume  that  you’re  running  a  Ruby  on  Rails  applica1on  with  Unicorn,  Thin,  Puma  or  any  other  Rack  based  Ruby  webserver.    To  instead  configure  Apache/nginx  as  the  entry  point,  see  here.  
    • This  can  be  a  load  balancer,  Apache/nginx  or  Ruby  itself.      Successive  hosts  and  soKware  stacks  that  requests  pass  through  will  act  appropriately  according  to  upstream  seWngs.!
    • If  you  setup  Apache  or  nginx  as  your  entry  point  then  you  can  skip  this  part  enErely.    The                      gem  will  take  it’s  tracing  instrucEons  from  upstream  automaEcally.  Oboe!
    • When  the                    gem  is  installed  in  your  applica1on,  it  makes  available    !!which  is  a  nested  hash  of  configura1on  op1ons  that  affect  how  your  applica1on  is  instrumented.  Oboe::Config !Oboe!
    • Luckily,  the  defaults  are  very  smart  and  only  a  couple  ini1al  values  need  to  be  configured.    The  two  required  values  are:    Oboe::Config[:tracing_mode] = always !Oboe::config[:sample_rate] = 100000 # 10% of incoming requests !
    • These  values  enable  tracing  (:tracing_mode)  and  sets  the  sample  rate  to  10%  (:sample_rate).    The  sample_rate  is  calculated  by  the  value  out  of  one  million.      e.g.  300000  would  equal  a  30%  sample  rate  meaning  3  out  of  10  requests  would  be  sampled.      (For  low  traffic  sites,  you  may  want  to  set  these  values  higher.)!
    • These  values  are  usually  set  in  a  Rails  ini1alizer  for  Ruby  on  Rails.      See  the  OpEonal  Rails  IniEalizer  sec1on  on  this  page.      A  complete  list  of  all  configura1on  op1ons  for   is  here.!Oboe::Config !
    • And  that’s  it.  Now  to  the  good  stuff…!
    • GeWng  Performance  Data    
    • If  you  want  to  test  that  the  oboe  gem  is  func1onal,  start-­‐up  a  Rails  console,  you  should  see  a  message  to  stdout  similar  to:     Tracelytics oboe gem 1.4.0.2 successfully loaded. !
    • Note  that  on  hosts  that  don’t  have  the  system  daemon  installed,  the  oboe  gem  disables  itself  and  outputs  a  message  to  that  fact:        Deploy/restart  your  applica1on  and  you  should  start  seeing  traces  show  up  in  your  TraceView  dashboard  aKer  a  couple  minutes.  Unsupported Tracelytics environment (no libs). Going No-op. !
    • Things  are  moving  fast  for  the  Ruby  language  instrumenta1on  in  TraceView.      We  support  tracing  of:          
    • memcache-­‐client,  memcached,    dalli,  mongo,    moped,  mongoid,  mongomapper,  cassandra,    Ac1veRecord  (postgres,  mysql,  mysql2)        …plus  more.    
    • Most  recently  we  added  support  for  Rack  and  Resque  tracing.    For  a  full-­‐list  of  supported  libraries,  see  this  ar1cle.!
    • Extras:    Some  Random  Chart  Porn    
    • A  screenshot  that  I  sent  to  Linode  when  performance  unexpectedly  dropped:    
    • Linode  migrated  my  VPS  to  a  lesser  u1lized  host  with  evident  results    (Thanks  Linode):    
    • An  older  issue  that  Gameface  had  with  atrocious  rendering  1mes:    
    • If  you  haven’t  tried  out  TraceView  yet,  give  it  a  run.      You  won’t  be  disappointed.      Note:  AppNeta  now  offers  free  tracing  for  single  projects.  Check  it  out  on  their  pricing  page.