pinterest-for-woocommerce icon indicating copy to clipboard operation
pinterest-for-woocommerce copied to clipboard

Optimize backend calls to frequently used endpoints.

Open budzanowski opened this issue 1 year ago • 0 comments

Intro

This is a master Issue that will track work on all of the endpoints mentioned below. I expect that optimizations for each endpoint should be delivered via separate PRs for better separation and tracking.

Tracking progress

### Tasks
- [ ] https://github.com/woocommerce/pinterest-for-woocommerce/issues/797
- [ ] https://github.com/woocommerce/pinterest-for-woocommerce/issues/798
- [ ] https://github.com/woocommerce/pinterest-for-woocommerce/issues/799
- [ ] https://github.com/woocommerce/pinterest-for-woocommerce/issues/800

User story

Adarsha has observed that commerce/product_pin_merchants/{$merchant_id}/ API endpoint is being called over 100k requests per hour (averaging around 4 requests per hour per user). This high traffic to the API endpoint could potentially be causing unnecessary load on our servers and slowing down our application performance. The same has been noticed on get advertiser countries, get advertiser discounts, and get feed profiles for merchants.

Is your feature request related to a problem?

The issue is related to the optimization of our backend operations. The overuse of these endpoints is not necessarily causing a problem right now, but it may in the future if left unchecked. It could lead to an unnecessary increase in costs and could potentially slow down our application for users.

How to reproduce the problem

  1. Monitor API calls to the commerce/product_pin_merchants/{$merchant_id}/ endpoint.
  2. Observe the number of calls made per user, per hour.

Describe the solution you'd like

I propose that we review the frequency and necessity of these API calls. It may be possible to reduce the number of requests or to implement caching or batch processing where appropriate.

Technical

A technical review of the backend code related to these API endpoints is necessary. This would involve inspecting how and where these API calls are made and determining if there are more efficient ways to achieve the same results.

Figma link

Not applicable.

Acceptance criteria

  • [ ] Conduct a thorough review of the usage of these API endpoints.
  • [ ] Propose a plan to reduce the number of API calls or increase efficiency.
  • [ ] Implement the proposed changes.
  • [ ] Monitor the usage of the API endpoints after implementation to ensure the changes have had the desired effect.

Unknowns

  • [ ] We need to identify the parts of the application that are making these calls, and why they're doing so frequently.
  • [ ] What are the possible implications on the application's functionality if we reduce the number of API calls?

Out of bounds/rabbit holes

  • Rewriting major parts of the backend is out of scope for this issue. Our aim should be to optimize the existing system.

budzanowski avatar Jul 24 '23 14:07 budzanowski