SlideShare a Scribd company logo
1 of 23
It Works On Dev ByMarcel Esser Code Samurai, CROSCON Contact +1 202 730 9728 +49 176 785 69729 marcel.esser@croscon.com
The Many Faces of Bugs What are bugs, really? On dev, a bug is an oversight or human error. We’ve used x or y incorrectly, or our flow control is incorrect. On test, a bug is a failed assertion; x does not equal y, although it’s supposed to. On stage, a bug is handbrake. You can recover gracefully and roll back. On live, any problem is a bug. It prevents the normal course of business operations.
Prevention An apple a day…
Prevention: Overview How do I prevent live bugs? Practice pre-emptive warfare.Encourage behavior and practices that detect bugs early. Automate processes to prevent human error.If an action can be automated with reasonable effort, do so. Monitor the eco-system.Your application is not just PHP; it’s the entire platform. Work smarter.Identify where investing more time yields greater rewards.
Prevention: Pre-emptive Warfare Things you should do: Write unit tests (and preferably, follow TDD). K.I.S.S. Complicated code is hard to maintain. Develop functional tests (for example, Selenium IDE). Re-factor often. Maintain automatic documentation (for example, phpdoc). Ask someone stupid. Know your tools.
Prevention: Automation Automation Examples Write scripts to push your configuration and application files to your staging and production machines. rsync and ssh work great. Test upgrades and reconfigurations on dev->test and script them for dev->stage. This is your test for pushing to production. Run customized functional test suites against live after pushes to ensure that your code works as expected.
Prevention: Automation Production Push from SVN #!/bin/sh sshroot@prod "/etc/init.d/apache2 stop" rm -rf /tmp/x; mkdir -p /tmp/x svn export https://devs/svn/repo/tags/STABLE /tmp/x/ rsync -avz /tmp/x/ root@prod:/var/www/app/ sshroot@prod "/etc/init.d/apache2 start"
Prevention: Monitoring Monitoring: Best effort to lazy time ratio Sometimes bugs aren’t bugs; monitor your application servers to keep track of resource usage and predict load situations. For example, Munin or Zabbix. Use a service-monitoring tool such as Nagios or Zabbix to script actions that ensure your application is available. If you are doing background processing, develop scripts to monitor the status of your custom daemons.
Prevention: Be Smarter Working a little smarter Don’t fix problems twice. Keep a log. When you think of a potential problem, make a note. Don’t assume. Create incentives for bug killers. Schedule time for preventative work.
Debugging on live? Surely, you jest.
Debugging on live? Where do live bugs come from? Very common causes: Differences between dev/test/stage/live platforms. Differences in application state (for example, the database). Differences in configuration. Differences in hardware. Poor quality assurance. Incorrect assumptions.
Debugging on live? How to Gather Intelligence on Live Your objectives: Bug reports Profiling Tracing Remote debugging Identifying bugs in your application server
Debugging on live: Bug reports What’s a good bug report? Ideally, you have: The account of the user that experienced the error. The page that generated the error. What the user was doing before the error occurred. The user’s client software. Competent support personnel.
Debugging on live: Profiling What is Xdebug? PHP debugging extension written by DerickRethans. It profiles. It traces. It breakpoints. It has good client support (Eclipse/NetBeans). Zend Debugger is also good – but not everyone has it.
Debugging on live: Profiling with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so# enable debugging trigger # i.e. XDEBUG_PROFILE=1 in GET, POST,# or cookie xdebug.profiler_enable_trigger = 1 # where to save profile output xdebug.profiler_output_dir = /tmp # filename specifier; <path>.<time>.out xdebug.profiler_output_name = %s.%t.out
Debugging on live: Profiling with Xdebug Visit your URL:http://127.0.0.1/cake_1.2.5/?XDEBUG_PROFILE=1 2) Grab the profile dump from the server. 3) Fire up KCacheGrind. 4) Profit.
Debugging on live: Tracing with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so # turn on automatic tracing xdebug.auto_trace=On # where to store the tracedumps xdebug.trace_output_dir=/tmp/ # more memory reporting, please xdebug.show_mem_delta=On
Debugging on live: Tracing with Xdebug Visit your URL:http://127.0.0.1/worksondev/index.php 2) Grab the trace dump from the server. 3) Fire up a text editor. 4) Profit.
Debugging on live: Debugging with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so # turn on automatic tracing xdebug.remote_enable = on # debugger protocolxdebug.remote_handler=dbgp # debugger client hostxdebug.remote_host=localhost # debugger client portxdebug.remote_port=9000
Debugging on live: A Word of Caution Before you get ahead of yourself… A couple of notes about remote debugging: There is a performance penalty. Enable it only when you need to, and turn it off after you get your data. Remember that debugging information is extremely sensitive and should be kept confidential. Use automatic scripts to turn debug extensions/settings on/off automatically so you don’t accidentally leave “leavings”.
Debugging on live: Identifying Server Bugs When All Else Fails Remember that you are computer programmers and: Take the problem machine out of rotation. Setup Apache/Yourwebserver to spawn 1 worker process. Attach a tracer to that process, like strace or dtrace. Figure out where it dies. Map that to the appropriate PHP code or extension. Don’t do whatever you did.
Oh, and btw. In case you forgot…
Shameless Plug Hi, my name is Marcel Esser. I work for CROSCON. We do:  Bespoke application development Customized service monitoring MyCourt productivity software Info? marcel.esser@croscon.com 202.730.9728

More Related Content

What's hot

JDK, the not so hidden treasures
JDK, the not so hidden treasuresJDK, the not so hidden treasures
JDK, the not so hidden treasuresAndrzej Grzesik
 
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop ArcWebinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arcjguerrero999
 
JDK not so hidden treasures
JDK not so hidden treasuresJDK not so hidden treasures
JDK not so hidden treasuresAndrzej Grzesik
 
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00YouheiYamada
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsTesting and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsOtto Kekäläinen
 

What's hot (7)

Mangling
Mangling Mangling
Mangling
 
JDK, the not so hidden treasures
JDK, the not so hidden treasuresJDK, the not so hidden treasures
JDK, the not so hidden treasures
 
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop ArcWebinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc
Webinar: Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc
 
JDK not so hidden treasures
JDK not so hidden treasuresJDK not so hidden treasures
JDK not so hidden treasures
 
Web pack and friends
Web pack and friendsWeb pack and friends
Web pack and friends
 
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00
Hands on - JetBrains IDE Rider C# 01-GetStarted r01.00
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsTesting and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressions
 

Similar to How to Prevent and Debug Bugs Across Development Stages

5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry AboutIndus Khaitan
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldLorna Mitchell
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 
Lightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingLightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingNick Burwell
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
How to drive a malware analyst crazy
How to drive a malware analyst crazyHow to drive a malware analyst crazy
How to drive a malware analyst crazyMichael Boman
 
44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy44CON
 
debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).pptjerlinS1
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...jeyasrig
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging TechniquesWebStackAcademy
 
AppSec California 2016 - Making Security Agile
AppSec California 2016 - Making Security AgileAppSec California 2016 - Making Security Agile
AppSec California 2016 - Making Security AgileOleg Gryb
 
Troubleshooting Plone
Troubleshooting PloneTroubleshooting Plone
Troubleshooting PloneRicado Alves
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Controlelliando dias
 
Groovy for System Administrators
Groovy for System AdministratorsGroovy for System Administrators
Groovy for System AdministratorsDaniel Woods
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingZendCon
 

Similar to How to Prevent and Debug Bugs Across Development Stages (20)

Fuzzing - Part 2
Fuzzing - Part 2Fuzzing - Part 2
Fuzzing - Part 2
 
Xdebug
XdebugXdebug
Xdebug
 
Deployment talk dpc 13
Deployment talk dpc 13Deployment talk dpc 13
Deployment talk dpc 13
 
Download It
Download ItDownload It
Download It
 
5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
 
Power Of Zero
Power Of ZeroPower Of Zero
Power Of Zero
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Lightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingLightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error Handling
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
How to drive a malware analyst crazy
How to drive a malware analyst crazyHow to drive a malware analyst crazy
How to drive a malware analyst crazy
 
44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy
 
debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).ppt
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
AppSec California 2016 - Making Security Agile
AppSec California 2016 - Making Security AgileAppSec California 2016 - Making Security Agile
AppSec California 2016 - Making Security Agile
 
Troubleshooting Plone
Troubleshooting PloneTroubleshooting Plone
Troubleshooting Plone
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Control
 
Groovy for System Administrators
Groovy for System AdministratorsGroovy for System Administrators
Groovy for System Administrators
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server Tracing
 

Recently uploaded

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

How to Prevent and Debug Bugs Across Development Stages

  • 1. It Works On Dev ByMarcel Esser Code Samurai, CROSCON Contact +1 202 730 9728 +49 176 785 69729 marcel.esser@croscon.com
  • 2. The Many Faces of Bugs What are bugs, really? On dev, a bug is an oversight or human error. We’ve used x or y incorrectly, or our flow control is incorrect. On test, a bug is a failed assertion; x does not equal y, although it’s supposed to. On stage, a bug is handbrake. You can recover gracefully and roll back. On live, any problem is a bug. It prevents the normal course of business operations.
  • 4. Prevention: Overview How do I prevent live bugs? Practice pre-emptive warfare.Encourage behavior and practices that detect bugs early. Automate processes to prevent human error.If an action can be automated with reasonable effort, do so. Monitor the eco-system.Your application is not just PHP; it’s the entire platform. Work smarter.Identify where investing more time yields greater rewards.
  • 5. Prevention: Pre-emptive Warfare Things you should do: Write unit tests (and preferably, follow TDD). K.I.S.S. Complicated code is hard to maintain. Develop functional tests (for example, Selenium IDE). Re-factor often. Maintain automatic documentation (for example, phpdoc). Ask someone stupid. Know your tools.
  • 6. Prevention: Automation Automation Examples Write scripts to push your configuration and application files to your staging and production machines. rsync and ssh work great. Test upgrades and reconfigurations on dev->test and script them for dev->stage. This is your test for pushing to production. Run customized functional test suites against live after pushes to ensure that your code works as expected.
  • 7. Prevention: Automation Production Push from SVN #!/bin/sh sshroot@prod "/etc/init.d/apache2 stop" rm -rf /tmp/x; mkdir -p /tmp/x svn export https://devs/svn/repo/tags/STABLE /tmp/x/ rsync -avz /tmp/x/ root@prod:/var/www/app/ sshroot@prod "/etc/init.d/apache2 start"
  • 8. Prevention: Monitoring Monitoring: Best effort to lazy time ratio Sometimes bugs aren’t bugs; monitor your application servers to keep track of resource usage and predict load situations. For example, Munin or Zabbix. Use a service-monitoring tool such as Nagios or Zabbix to script actions that ensure your application is available. If you are doing background processing, develop scripts to monitor the status of your custom daemons.
  • 9. Prevention: Be Smarter Working a little smarter Don’t fix problems twice. Keep a log. When you think of a potential problem, make a note. Don’t assume. Create incentives for bug killers. Schedule time for preventative work.
  • 10. Debugging on live? Surely, you jest.
  • 11. Debugging on live? Where do live bugs come from? Very common causes: Differences between dev/test/stage/live platforms. Differences in application state (for example, the database). Differences in configuration. Differences in hardware. Poor quality assurance. Incorrect assumptions.
  • 12. Debugging on live? How to Gather Intelligence on Live Your objectives: Bug reports Profiling Tracing Remote debugging Identifying bugs in your application server
  • 13. Debugging on live: Bug reports What’s a good bug report? Ideally, you have: The account of the user that experienced the error. The page that generated the error. What the user was doing before the error occurred. The user’s client software. Competent support personnel.
  • 14. Debugging on live: Profiling What is Xdebug? PHP debugging extension written by DerickRethans. It profiles. It traces. It breakpoints. It has good client support (Eclipse/NetBeans). Zend Debugger is also good – but not everyone has it.
  • 15. Debugging on live: Profiling with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so# enable debugging trigger # i.e. XDEBUG_PROFILE=1 in GET, POST,# or cookie xdebug.profiler_enable_trigger = 1 # where to save profile output xdebug.profiler_output_dir = /tmp # filename specifier; <path>.<time>.out xdebug.profiler_output_name = %s.%t.out
  • 16. Debugging on live: Profiling with Xdebug Visit your URL:http://127.0.0.1/cake_1.2.5/?XDEBUG_PROFILE=1 2) Grab the profile dump from the server. 3) Fire up KCacheGrind. 4) Profit.
  • 17. Debugging on live: Tracing with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so # turn on automatic tracing xdebug.auto_trace=On # where to store the tracedumps xdebug.trace_output_dir=/tmp/ # more memory reporting, please xdebug.show_mem_delta=On
  • 18. Debugging on live: Tracing with Xdebug Visit your URL:http://127.0.0.1/worksondev/index.php 2) Grab the trace dump from the server. 3) Fire up a text editor. 4) Profit.
  • 19. Debugging on live: Debugging with Xdebug # load as a ZE extensionzend_extension=/path/xdebug.so # turn on automatic tracing xdebug.remote_enable = on # debugger protocolxdebug.remote_handler=dbgp # debugger client hostxdebug.remote_host=localhost # debugger client portxdebug.remote_port=9000
  • 20. Debugging on live: A Word of Caution Before you get ahead of yourself… A couple of notes about remote debugging: There is a performance penalty. Enable it only when you need to, and turn it off after you get your data. Remember that debugging information is extremely sensitive and should be kept confidential. Use automatic scripts to turn debug extensions/settings on/off automatically so you don’t accidentally leave “leavings”.
  • 21. Debugging on live: Identifying Server Bugs When All Else Fails Remember that you are computer programmers and: Take the problem machine out of rotation. Setup Apache/Yourwebserver to spawn 1 worker process. Attach a tracer to that process, like strace or dtrace. Figure out where it dies. Map that to the appropriate PHP code or extension. Don’t do whatever you did.
  • 22. Oh, and btw. In case you forgot…
  • 23. Shameless Plug Hi, my name is Marcel Esser. I work for CROSCON. We do: Bespoke application development Customized service monitoring MyCourt productivity software Info? marcel.esser@croscon.com 202.730.9728