DevPath icon indicating copy to clipboard operation
DevPath copied to clipboard

Bug: Missing caching on career pathway queries causes slow response times and database overload

Open anshul23102 opened this issue 5 months ago • 10 comments

Problem Statement

DevPath does not implement caching for career pathway data, causing redundant database queries on every user request. This leads to slow response times, high database load, and poor user experience especially for popular career paths requested frequently.

Root Cause Analysis

Career data queries hit database every request without caching layer. No Redis or in-memory cache. No cache invalidation strategy. Database queries not optimized with indexes. No pagination on large result sets.

Solution Overview

  1. Implement Redis caching for career pathway data
  2. Set appropriate TTL (time-to-live) based on update frequency (3600s for hourly updates)
  3. Implement cache invalidation on data updates
  4. Add database query optimization with indexes
  5. Implement pagination for large datasets
  6. Add cache warming on application startup
  7. Monitor cache hit/miss rates
  8. Use compression for large cached objects

Type of Change

  • [x] Bug fix (performance)
  • [ ] New feature
  • [ ] Breaking change
  • [ ] Documentation update

Testing Done

Environment

  • Node.js 18.x+
  • Redis
  • Database with indexes

Manual Testing Steps

Test Case 1: Response time without cache

  1. Request career pathway data
  2. Measure response time

Expected: Response time < 100ms with cache Actual: Response time 1000ms+ hitting database every time

Related Issue

Improves application performance and reduces database load.

Suggested Labels

bug, level:intermediate, gssoc26, performance, caching, database-optimization

anshul23102 avatar Jun 06 '26 15:06 anshul23102

Hey @komalharshita , this is my proposed solution,

  • Add a Redis middleware in your API route handler (e.g., routes/careers.js) to check cache before querying, and update db/queries.js to add indexes and pagination parameters.
  • On data mutations in controllers/careerController.js, call redis.del(cacheKey) to invalidate stale cache, and add a scripts/warmCache.js startup script that pre-loads popular career paths into Redis on app boot.

Can you assign this to me Under gssoc26, thank you for your time.

HimanshuGaur14 avatar Jun 06 '26 17:06 HimanshuGaur14

/assign

nensii21 avatar Jun 08 '26 10:06 nensii21

/assign

avanibapna06 avatar Jun 19 '26 18:06 avanibapna06

I'd like to work on this — contributing under GSSoC'26

mahavirb22 avatar Jun 22 '26 09:06 mahavirb22

/assign

kumarishreya-ai-ds avatar Jun 23 '26 06:06 kumarishreya-ai-ds

/assign gssoc'26

AQUA1310 avatar Jun 28 '26 16:06 AQUA1310

/claim Hi @komalharshita ,

I would love to take ownership of this performance optimization issue under GSSoC '26.

I understand that caching and query optimization are critical for scaling the application. Here is my comprehensive plan to implement the solution outlined in the issue description:

Proposed Technical Approach:

  • Caching Layer (Redis):
    • Integrate a Redis client and create a caching middleware for the career pathway GET routes.
    • Implement a 3600s TTL for the cached data and use payload compression (e.g., Brotli or Gzip) for large JSON responses to optimize memory.
  • Cache Management:
    • Implement cache invalidation hooks in the respective POST/PUT/DELETE controllers to clear stale data automatically.
    • Create a lightweight warmCache.js utility that runs on application startup to preload the top 10-20 most requested career pathways.
  • Database Optimization:
    • Update the database schema/migrations to add indexes to the most frequently queried fields (e.g., pathway names, categories).
    • Implement standard limit and offset (or cursor-based) pagination on the backend and ensure the frontend handles the paginated responses properly.

I am comfortable working with Node.js, Redis, and database indexing. Please let me know if you have a preferred Redis hosting setup for local testing (e.g., Docker). I would be thrilled if you could assign this to me!

hemag111 avatar Jul 01 '26 03:07 hemag111

Hi @komalharshita, I'd like to work on this. Plan: add an in-process TTL cache (or Redis-backed cache if the project already has a Redis dependency) keyed by pathway/user parameters in front of the career pathway query path, with explicit invalidation on any write to pathway data, and a benchmark showing query count/latency before vs. after. Requesting assignment under GSSoC 2026.

/assign /claim

anshul23102 avatar Jul 05 '26 17:07 anshul23102

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Nov 11 '26 07:11 github-actions[bot]

This issue was closed because it has been inactive for an extended period. If this issue is still relevant, feel free to reopen it or create a new one.

github-actions[bot] avatar Nov 18 '26 08:11 github-actions[bot]