Homework & Coding Practice

Homework/Practice Coding Assignment (20-min)

Step-by-Step Procedure

  1. Profile the API Built in Lesson 7 and Identify Areas for Performance Improvement:

    • Step 1: Run the API with clinic:

      bash코드 복사clinic flame -- node server.js
    • Step 2: Use Postman to test all endpoints:

      • GET /tasks.

      • POST /tasks.

      • PUT /tasks/:id.

      • DELETE /tasks/:id.

    • Step 3: Analyze the flamegraph:

      • Look for blocking tasks.

      • Check the time taken for database or JSON processing.

    • Step 4: Optimize the API:

      • Replace synchronous operations (e.g., fs.readFileSync) with asynchronous ones.

      • Ensure routes are properly optimized for performance.

  2. Write a Summary of Your Debugging Experience:

    • Key Points to Address:

      1. Tools used for debugging (debugger, clinic).

      2. Common issues identified and their root causes.

      3. Steps taken to resolve issues.

      4. Insights gained from profiling and performance metrics.


Example Summary:

markdown코드 복사Debugging Experience Summary:
1. Tools: Used `debugger` and `clinic.js` for identifying issues.
2. Issues: Found unoptimized synchronous operations in the `/tasks` route.
3. Solutions: Replaced blocking tasks with asynchronous calls and added proper error handling.
4. Outcome: Improved response time and reduced CPU usage.

Expected Outcomes

  1. Students gain hands-on experience with debugging and profiling Node.js applications.

  2. Students learn to identify and resolve performance bottlenecks using tools like clinic.js.

  3. Homework reinforces best practices for debugging and optimization in real-world applications.

Last updated