COURSE 4 – TROUBLESHOOTING AND DEBUGGING TECHNIQUES

Module 4: Managing Resources

GOOGLE IT AUTOMATION WITH PYTHON PROFESSIONAL CERTIFICATE

Complete Coursera Study Guide

Last updated:

INTRODUCTION – Managing Resources

In this module, you’ll learn how to manage your applications. You’ll dive into some common issues that may cause your application to crash. You’ll also understand what memory leaks are, and how to troubleshoot and prevent them. Up next, you’ll run down managing disk space; you’ll see some scenarios of how this happens and how to identify what process or application is taking up all your disk space. Then, you’ll learn what network saturation is, how it can be caused, and some useful tools and techniques to solve a network saturation problem. Next, we’ll shift from managing applications to managing your time. You’ll get tips on how to prioritize tasks, estimate how long a particular task will take before finishing, and communicate expectations when dealing with important tasks. The final lesson delves into how to deal with hard and complex problems by breaking it down into small, digestible chunks while keeping your eyes on a clear goal. You’ll learn that using proactive approaches, like continuous integration, can help you with future issues that might come up. You’ll also explore how to plan for future resource usage by making good use of monitoring.

Learning Objectives

  • Understand how to manage disk space, avoid network saturation, and manage memory leaks
  • Utilize their techniques to manage their time correctly by prioritizing tasks and estimating how long tasks will take
  • Understand the importance of communicating expectations of completing tasks, fixes, and bugs
  • Understand how to deal with complex problems by breaking them down
  • Utilize proactive approaches like continuous integration or having a test environment
  • Utilize best practices when planning for the future

PRACTICE QUIZ: MANAGING COMPUTER RESOURCES

1. What is a memory profiler used for?

  • It is used to store information. 
  • It profiles an entire Python application.
  • It monitors memory consumption of a process over time, as well as the variables that require the most memory. (CORRECT)
  • It modifies code.

Nice job! Memory profiler is a module that provides useful information about memory. 

2. Your application is having difficulty sending and receiving large packets of data, which are also delaying other processes when connected to remote computers. Which of the following will be most effective on improving network traffic for the application?

  • Running the iftop program
  • Increase storage capacity
  • Increase memory capacity
  • Use traffic shaping (CORRECT)

Right on! Traffic shaping can mark data packets and assign higher priorities when being sent over the network.

3. What is the term referring to the amount of time it takes for a request to reach its destination, usually measured in milliseconds (ms)?

  • Bandwidth
  • Latency (CORRECT)
  • Number of connections
  • Traffic shaping

Awesome! Latency is a measure of the time it takes for a request to reach its destination.

4. If your computer is slowing down, what Linux program might we use to determine if we have a memory leak and what process might be causing it?

  • top (CORRECT)
  • gparted
  • iftop
  • cron

Great work! The top command will show us all running processes and their memory usage in Linux.

5. Some programs open a temporary file, and immediately _____ the file before the process finishes, then the file continues to grow, which can cause slowdown.

  • open
  • close
  • delete (CORRECT)
  • write to

Excellent! Sometimes a file is marked as deleted right after it is opened, so the program doesn’t “forget” later. The file is then written to, but we can’t see this as the file is already marked as deleted, but will not actually be deleted until the process is finished.

6. Which of the following descriptions most likely points to a possible memory leak?  

  • Application process uses more memory even after a restart. (CORRECT)
  • Garbage collector carries out its task.  
  • The function returns after it completes.  
  • Valgrind figures out memory usage.  

Woohoo! An app that still needs a lot of memory, even after a restart, most likely points to a memory leak.  

7. Which of the following is an example of unnecessary files on a server storage device that can affect applications from running if not cleaned up properly?  

  • A SQL database  
  • A mailbox database  
  • A set of application files  
  • A set of large temporary files (CORRECT)

You nailed it! Large temporary files may remain if an application crashes because it’s not cleaned up automatically.  

8. The custom application running on a server can’t receive new connections. Existing connections are sending and receiving data in a reasonable time. Which of the following explains the reason why new sessions can’t be established with the server?

  • Too many connections (CORRECT)
  • High network latency  
  • Low network bandwidth  
  • No traffic shaping 

Great work! There are limits to how many connections a single server can have, which will prevent new connections.  

PRACTICE QUIZ: MANAGING OUR TIME

1. Using the Eisenhower Decision Matrix, which of the following is an example of an event or task that is both Important, and Urgent?

  • Office gossip
  • Replying to emails
  • Internet connection is down (CORRECT)
  • Follow-up to a recently resolved issue

Great work! It’s important for users to have Internet to work, and it must be resolved right away.

2. You’re working on a web server issue that’s preventing all users from accessing the site. You then receive a call from user to reset their user account password. Which appropriate action should you take when prioritizing your tasks?

  • Reset the user’s password
  • Create a script to automate password resets
  • Ask the user to open a support ticket.
  • Ignore the user, and troubleshoot web server. (CORRECT)

Nice job! Ask the user to open a support ticket so that the request can be placed into the queue while you work on the most urgent issue at hand.

3. What is it called when we make more work for ourselves later by taking shortcuts now?

  • Technical debt (CORRECT)
  • Ticket tracking
  • Eisenhower Decision Matrix
  • Automation

Right on! Technical debt is defined as the implied cost of additional rework caused by choosing an easy (limited) solution now instead of using a better, but more difficult, solution.

4. What is the first step of prioritizing our time properly?

  • Work on urgent tasks first
  • Assess the importance of each issue
  • Make a list of all tasks (CORRECT)
  • Estimate the time each task will take

Awesome! Before we can even decide which task to do first, we need to make a list of our tasks.

5. If an issue isn’t solved within the time estimate that you provided, what should you do? (Select all that apply)

  • Explain why (CORRECT)
  • Drop everything and perform that task immediately
  • Give an updated time estimate (CORRECT)
  • Put the task at the end of the list

Nice work! Communication is key, and it’s best to keep everyone informed.

Great work! If your original estimate turned out to be overly optimistic, it’s appropriate to re-estimate.

6. Which of the following describes a technical debt?  

  • Restarting a web server that has suspended services. (CORRECT)
  • Rewriting a program to prevent memory leaks.  
  • Setting up traffic shaping to improve communication with remote services.  
  • Adding a hard drive to make room to install the application.  

You got it! Restarting a server is a quick-fix or short-term remediation, which is also known as technical debt.  

7. Using a basic structure to organize and prioritize tasks, what’s the next thing you should do after creating a list of all the tasks you need to complete?  

  • Sort tasks in groups.  
  • Assess the importance of each issue.  
  • Complete most urgent tasks immediately. (CORRECT)
  • Estimate the amount of effort.

Woohoo! The most urgent tasks should be done immediately after completing the list.  

8. Which of the following factors will be most beneficial in estimating the time it will take for you to complete a specific project?  

  • Be overly optimistic with your time.  
  • Multiply the estimate by a random factor.  
  • Double your time.  
  • Compare time used to similar projects or tasks. (CORRECT)

You nailed it! The best way to estimate time on a new project is to compare your estimate to similar tasks or projects completed previously.   

9. Which of the following is an example of a practical shortcut to resolve incidents in a datacenter related to hard drive pre-failures?  

  • Spare drives (CORRECT)
  • Automated RAID scripts  
  • Spare servers  
  • Automated server scripts. 

Right on! Spare drives are a practical shortcut that can quickly replace hard drives in a pre-fail state.  

PRACTICE QUIZ: MAKING OUR FUTURE LIVES EASIER

1. Which proactive practice can you implement to make troubleshooting issues in a program easier when they happen again, or face other similar issues?

  • Automate rollbacks.
  • Create and update documentation. (CORRECT)
  • Use a test environment.
  • Set up unit tests.

You got it! Documentation that includes good instructions on how to resolve an issue can assist in resolving the same or similar issue in the future.

2. Which of the following is a good example of mixing and matching resources on a single server so that the running services make the best possible use of all resources?

  • Run a RAM intensive application and a CPU intensive application on a server. (CORRECT)
  • Run two applications that are CPU intensive between two servers.
  • Run a CPU intensive application on one server and an I/O intensive application on another server.
  • Run two applications that are RAM and I/O intensive on a server.

Great work! An application that uses a lot of RAM can still run, while the CPU is mostly used by another application on the same server.

3. One strategy for debugging involves explaining the problem to yourself out loud. What is this technique known as?

  • Monitoring
  • Rubber ducking (CORRECT)
  • Testing
  • Ticketing

Right on! Rubber ducking is the process of explaining a problem to a “rubber duck,” or rather yourself, to better understand the problem. 

4. When deploying software, what is a canary? 

  • A test for how components of a program interact with each other
  • A test of a program’s components
  • A small section of codeA test deployment to a subset of production hosts (CORRECT)

Nice job! Reminiscent of the old term “canary in a coal mine,” a canary is a test deployment of our software, just to see what happens.

5. Which term describes a component of a system that might fail logically or physically?

  • I/O intensive
  • CPU intensive
  • A problem domain
  • A failure domain (CORRECT)

Awesome! A failure domain is a logical or physical component of a system that might fail.

6. What is the primary goal of change management in virtualized environments?

  • Maximizing disruptions and system changes
  • Rapidly implementing changes to VM infrastructure
  • Ensuring system integrity and minimizing disruption (CORRECT)
  • Safeguarding VMs from unauthorized access

That’s correct! The goal of virtualized change management is to maintain system integrity and minimize disruptions by following a structured approach when making changes to the VM’s infrastructure. 

7. When should you NOT use Docker to manage applications?

  • Running a large, monolithic legacy application (CORRECT)
  • Using Docker to deploy an application that has already been packaged as containers
  • When you are developing a microservice-based application
  • Running an application across hundreds or thousands of servers at internet scale

That’s right! Due to their complexity and resource requirements, legacy monolithic applications can be challenging to containerize and manage efficiently with Docker.

8. When it comes to software development, what does the term “problem domain” mean?

  • The failure of different subsystems within a complex system
  • A technical solution to a system failure 
  • The process of manually solving the problem using illustrative datasets
  • The scope and complexity of a problem that needs to be solved (CORRECT)

You got it! Problem domain refers to the scope and complexity of a specific problem. It involves understanding the nuances of the problem to more effectively develop solutions.

9. When facing a problem with a service, which of the following examples can remediate the issue quickly for the short-term?  

  • Create tests for the program before coding.  
  • Develop codes in small chunks.  
  • Ask someone who has solved the issue before for help. (CORRECT)
  • Grab a cup of coffee.  

Awesome! Someone who has solved the issue before can apply the short-term remediation right away, and long-term solutions can be discussed later.  

10. Which proactive practice can you implement to make troubleshooting issues in a program easier when problems arise?  

  • Use a test environment.  
  • Build infrastructure for rollbacks.  
  • Set up integration tests  
  • Include debug logging in code. (CORRECT)

Great work!. Including debug logging in code can make troubleshooting easier because logs can help pinpoint the actual issue, and speed up remediation.  

11. You have a small rack of servers and other components that make up a virtual infrastructure. This rack hosts virtual machines that provide web services, and user file shares to employees in the local office, and immediate regional branches. Which component in the rack can be most easily planned for future growth?  

  • CPU Capacity  
  • RAM Capacity  
  • NAS capacity (CORRECT)
  • Network bandwidth  

Nice job! Network Attached Storage (NAS) products from vendors like NetApp can provide additional shelves to add more storage as the website’s content, and users’ data increases in size.  

12. Which of the following is the most effective way to prevent an issue in a program that you own from happening again?  

  • Report a bug  
  • Write a test (CORRECT)
  • Monitor resources  
  • Reproduction case

Great work! When updating code to fix an issue, create a new test to ensure the change performs the intended actions.  

DEBUG AND SOLVE SOFTWARE PROBLEMS

1. What aspects of the date does the start_date_report.py script prompt the user to input? Select all that apply.

  • Year (CORRECT)
  • Hour
  • Month
  • Day (CORRECT)

Correct

2.  What was the specific cause of the TypeError in the start_date_report.py script?

  • Invalid file path specified
  • Incorrect data type for date components (year, month, day) (CORRECT)
  • Missing library import
  • Syntax error in the code

Correct

3. What steps did you take to reproduce the TypeError message in the start_date_report.py script? Select all that apply.

  • Use a debugging tool to trace the script’s execution and monitor variable states at error occurrence.
  • Run the script and enter varying year, month, and day values to trigger the error. (CORRECT)
  • Observe the script’s behavior when provided with out-of-range or non-numeric input scenarios. (CORRECT)
  • Modify the script code by altering function parameters to intentionally produce a similar error. 

Correct

4. In the context of the lab, which of the following is a key indicator that a script has been successfully optimized?

  • Ability to process larger files only
  • Reduced execution time to a few seconds for report generation (CORRECT)
  • Enhanced graphical user interface
  • Increased complexity for better accuracy

Correct

5. Which of the following best describes the error handling improvement needed in the start_date_report.py script?

  • Implementing additional checks for input data validity to avoid runtime errors
  • Optimizing the script for faster execution to prevent timeout errors
  • Refactoring the script to handle large datasets without crashing
  • Casting the user input values for year, month, and day to integers to prevent TypeError (CORRECT)

Correct

6. After you debugged the original error and fixed it, you discover that processing the file to print a report takes a long time. How do you fix this issue?

  • Nothing. Speed is dependent on the size of the dataset.
  • Run the Python script start_date_report.py earlier in the process. 
  • Check the execution time: time ./test.py. (CORRECT)
  • Modify the get_same_or_newer() function.

Correct

7. Based on your experience in the lab, which approach is most beneficial for identifying and resolving bugs in a complex script?

  • Sequentially address each bug, starting with the most critical or easiest to fix. (CORRECT)
  • Change the programming language or tools used to gain different perspectives on the bug.
  • Rely solely on automated debugging tools to identify and fix all issues.
  • Focus on optimizing the script’s performance before addressing specific bugs.

Correct

8. After debugging and fixing the initial problem in the lab, you need to optimize file processing and printing speed. What steps should you take for preprocessing the file? Select all that apply.

  • Create a dictionary using start dates as keys to replace repetitive calculations. (CORRECT)
  • Sequentially process the data starting from the earliest start_date.
  • Compile a dictionary to organize start dates for sequential use in the script. (CORRECT)
  • Sort the data by start_date, then process it date by date. (CORRECT)

Correct

9. In the lab, the get_same_or_newer() function in the start_date_report.py script was originally inefficient because it did which of the following? 

  • It generated unnecessary intermediate files during data processing, leading to increased disk I/O operations.
  • It used a complex and computationally expensive algorithm for sorting the data, slowing down each query.
  • It relied on external network resources for each data query, causing delays due to network latency.
  • It downloaded and processed the entire data file for each date queried, leading to excessive and repetitive data handling. (CORRECT)

Correct

10. What type of error caused the start_date_report.py script to crash?

  • SyntaxError
  • ValueError
  • FileNotFoundError
  • TypeError (CORRECT)

Correct

11. Finish this sentence: In the lab, to isolate and understand the conditions that caused the error, you _____.

  • reviewed the script’s documentation and code comments.
  • systematically reproduced the TypeError by running the script with various inputs. (CORRECT)
  • modified the script to include additional error logging.
  • consulted online resources for similar error patterns.

Correct

12. What caused the start_date_report.py script to crash?

  • The script crashed due to a TypeError caused by string inputs. (CORRECT)
  • The script had a ValueError due to invalid input range.
  • The script experienced a SyntaxError due to incorrect function usage.
  • The script crashed due to a FileNotFoundError.

Correct

13. In the lab, to enhance the performance of the start_date_report.py script, what specific preprocessing step is recommended for the data file?

  • Encrypt the file for secure and faster data processing.
  • Split the file into multiple smaller files for parallel processing.
  • Convert the file format to a more efficient data structure like JSON.
  • Create a dictionary from the file with start dates as keys for quicker data access. (CORRECT)

Correct

14. According to this QwikLab, what is an effective strategy for dealing with complex debugging issues like the ones encountered in the start_date_report.py script?

  • Implement automated testing to identify all issues at once.
  • Break down the problem into smaller, more manageable parts for targeted resolution. (CORRECT)
  • Consult online forums and communities for similar issues and solutions.
  • Completely rewrite sections of the script to avoid dealing with complex issues.

Correct

15. In the optimization process of the start_date_report.py script, why is creating a dictionary with start dates as keys an effective strategy?

  • It is a prerequisite for implementing multithreading in the script.
  • It simplifies the script’s code for easier maintenance.
  • It allows for rapid data retrieval without repeatedly scanning the entire dataset. (CORRECT)
  • It prepares the data for potential export to external systems.

Correct

16. In resolving the TypeError within the start_date_report.py script, which solution was implemented?

  • Importing an additional Python module
  • Correcting a file path in the script
  • Fixing a loop logic error
  • Casting string input to integers for year, month, and day (CORRECT)

Correct

17. Why is it important to reproduce the TypeError message encountered in the start_date_report.py script when debugging?

  • To ensure that the script is completely error-free.
  • To verify that the error consistently occurs under the same conditions.
  • To test the script’s performance under error conditions.
  • To understand the specific circumstances that lead to the error, enabling targeted debugging. (CORRECT)

Correct

18. After you debugged the original error and fixed it, you discover that processing the file to print a report takes a long time. How do you fix this issue?

  • Check the execution time: time ./test.py.
  • Nothing. Speed is dependent on the size of the dataset.
  • Run the Python script start_date_report.py earlier in the process. 
  • Modify the get_same_or_newer() function. (CORRECT)

Correct

19. Why does the lab suggest creating a dictionary with start dates as keys in the preprocessing step of the start_date_report.py script?

  • To enable complex statistical analysis on the start date data
  • To ensure data integrity by maintaining a unique record for each start date
  • To facilitate data export to external databases or systems
  • To improve performance by allowing quick access to employee records based on specific start dates, reducing the need to scan the entire file repeatedly (CORRECT)

Correct

20. In start_date_report.py, what is the primary benefit of sorting the data by start_date before processing it?

  • It ensures data integrity by maintaining chronological order.
  • It reduces the file size, making it easier to handle.
  • It enhances performance by allowing quicker access to relevant records for each date. (CORRECT)
  • It aligns the data format with standard database practices.

Correct

21. What is the primary outcome of preprocessing the file in the start_date_report.py script using the get_same_or_newer() function?

  • The function adapts to generate output dynamically based on demand, improving script responsiveness.
  • The function generates output that is reusable for multiple dates, reducing the need for repetitive calculations. (CORRECT)
  • The function enhances script efficiency by optimizing system resource usage, though the output remains the same.
  • The function restructures the dataset to expedite subsequent calculations by optimizing data order.

Correct

22. What is the expected performance improvement in the start_date_report.py script after optimization?

  • It should generate reports significantly faster. (CORRECT)
  • It should use less memory, irrespective of execution time.
  • It should allow handling more data but might take longer.
  • It should take about the same time but with fewer errors.

Correct

23. In the context of optimizing the start_date_report.py script, what is the primary role of the get_same_or_newer() function?

  • The function filters and processes employee data based on start dates. (CORRECT)
  • The function is responsible for generating graphical representations of the data.
  • The function calculates the total number of employees starting on a specific date.
  • The function is used to sort data by employee start dates.

Correct

24. What key principle should guide your approach to debugging complex problems, as exemplified in the lab’s challenges with the start_date_report.py script?

  • Prioritize the most recently introduced code changes as the likely source of bugs.
  • Apply the same debugging techniques used in simpler scripts, regardless of complexity.
  • Collaborate with a team to brainstorm potential solutions for all issues simultaneously.
  • Systematically analyze and resolve individual components of the problem to avoid being overwhelmed. (CORRECT)

Correct

25. How does preprocessing the file in the start_date_report.py script specifically address the problem of slow report generation?

  • It organizes data by start dates for efficient access, reducing the need for repetitive calculations. (CORRECT)
  • It compresses the file for quicker loading and processing times.
  • It cleans and sanitizes the data for error-free processing.
  • It indexes the file for faster search operations within the script.

Correct

26. You are optimizing a Python script similar to the one in the lab, designed to generate reports from a large dataset of employee start dates. The script currently processes the entire dataset each time a report for a specific date is requested, leading to slow performance. What change should you implement to improve the efficiency of the script?

  • Implement multithreading to process different parts of the dataset in parallel.
  • Increase the hardware resources allocated to the script, such as CPU and memory.
  • Rewrite the entire script using a more efficient programming language.
  • Modify the script to use the get_same_or_newer() function, which generates output that is reusable for multiple dates. (CORRECT)

Correct

27. In the start_date_report.py script, what corrections are needed to fix the TypeError encountered during execution? Select all that apply.

  • Cast month input to integer (CORRECT)
  • Cast day input to integer (CORRECT)
  • Cast hour input to integer
  • Cast year input to integer (CORRECT)

Correct

28. Complete this sentence. To fix the error found in the lab, you need to cast the data type of the year, month, and day values to _____. 

  • integers (CORRECT)
  • text and use the print () function
  • revise the call parameters
  • to concatenating strings

Correct

CONCLUSION – Managing Resources

In conclusion, this module has provided a comprehensive understanding of application management, covering various aspects from troubleshooting common issues to optimizing resource utilization and time management. You have gained insights into identifying and addressing factors that may lead to application crashes, including memory leaks and disk space management. Additionally, understanding network saturation and employing effective tools and techniques to resolve such issues has expanded your troubleshooting skills.

Transitioning to time management, you’ve acquired practical tips for task prioritization, time estimation, and effective communication, enabling you to maximize productivity and efficiency. Furthermore, the module has emphasized the importance of tackling hard and complex problems by breaking them down into manageable steps while maintaining focus on the end goal. By adopting proactive approaches like continuous integration and efficient resource monitoring, you are better equipped to anticipate and address future challenges effectively. Overall, this module equips you with the necessary knowledge and strategies to manage applications, time, and resources efficiently, facilitating smoother operation and problem-solving in your professional endeavors.