Remove custom eager loading in PlansFinder is possible
Problem
In the PlansFinder
currently, plans are eager loaded during app initialization. This is done as an optimization to reduce the number of requests to Zuora to fetch common products from the catalog. However, now that we are using IronBank's local products cache feature (with a slight customization to store in the db instead of filesystem), we might not need this eager-loading mechanism anymore.
Removing eager loading would have some nice benefits:
- Removes complexity in the app loading logic.
- Removes a few class variables from our codebase which in general should be avoided.
- Removes the eager-loading step from Rspec configuration. This would be a huge benefit because
plans_finder
has its own VCR cassette for this eager loading that frequently causes merge conflicts since it is a very commonly updated file. Fixing this should improve our velocity and generally the engineers quality of life.
Proposal
Remove the PlansFinder
eager-loading logic and make sure nothing breaks. The PlansFinder.find
method could be updated to find a Product Rate Plan directly using IronBank (e.g. Zuora::ProductRatePlan.find
) rather than looping over eager_loaded_plans
. The key difference here is we would build the Plan
object on the fly instead of returning a Plan
object that was built during start up.
We should take benchmarks of important features before and after this change to make sure there is no negative impact. Here are some ideas of things to benchmark:
- Loading the Rails app.
- Loading the Plans page.
- Loading the Manage subscriptions page.
- Making a subscription purchase.
Result
A simpler codebase that hopefully isn't any less performant but easier to maintain.