Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Optimization - Cache Provider Details #2249

Open
5 tasks
k-macmillan opened this issue Jan 16, 2025 · 0 comments
Open
5 tasks

DB Optimization - Cache Provider Details #2249

k-macmillan opened this issue Jan 16, 2025 · 0 comments

Comments

@k-macmillan
Copy link
Member

k-macmillan commented Jan 16, 2025

User Story - Business Need

Reducing the number of queries against our data is necessary to maintain a stable product. Provider details are not something that changes very often and can safely be cached.

  • Ticket is understood, and QA has been contacted (if the ticket has a QA label).

User Story(ies)

As a VA Notify reliability dev
I want to reduce unnecessary DB calls
So that our db is only used when necessary

Additional Info and Resources

client_to_use calls get_provider which seems to contain the offending method get_provider_details_by_id. The code can instead call a processing/caching method that makes that same call but translates the ORM object into a dataclass, so we don't have to keep looking up database "constants".

When it returns from get_provider it calls get_client_by_name_and_type, which looks up which initialized provider to use, so it appears no additional work needs to be done outside of "wrapping" the DAO method.

Image

Acceptance Criteria

  • Uses a dataclass for the necessary fields
  • Uses @cached(cache=TTLCache(maxsize=1024, ttl=600))
  • 10 notifications sent using the same provider should query the database at most once per worker
  • This work is added to the sprint review slide deck (key win bullet point and demo slide)

QA Considerations

Should be no difference for end-users.

Potential Dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants