prebid / prebid-server-java

Java version of Prebid Server
Apache License 2.0
66 stars 175 forks source link

Account settings via HttpPeriodicRefreshService #1665

Open jbartek25 opened 2 years ago

jbartek25 commented 2 years ago

Hey guys,

We are using a HTTP service for fetching accounts, requests and imps. This works fine when using HttpApplicationSettings but requires us to either periodically call the config services on predefined TTL intervals or the backend logic has to call the cache invalidation endpoint on each change.

Alternative approach is to use HttpPeriodicRefreshService which downloads all the config objects at the startup and then only fetches changed items on predefined interval. We like this approach more than what HttpApplicationSettings does but the problem is that HttpPeriodicRefreshService works only with requests and imps, not accounts. We could use HttpApplicationSettings for accounts and HttpPeriodicRefreshService for requests and imps but the downside of the approach is that we would need to

We looked at the code and as we see it, HttpPeriodicRefreshService cannot be easily extended to also fetch accounts, because HttpPeriodicRefreshService uses CacheNotificationListener which allows updating the cache directly but only supports requests and imps and it seems a rather large change to get accounts use the same caching mechanism as requests and imps.

Questions:

  1. Is there a plan in the near future to add support for fetching accounts via HttpPeriodicRefreshService?
  2. If answer on 1. is "no", we are testing a simplified implementation that we are happy to contribute: accounts would be fetched in HttpPeriodicRefreshService but instead of updating the account cache directly which is currently not possible, the cache of updated accounts would simply get invalidated and hence reloaded by HttpApplicationSettings (or any other fetch method configured).

Thanks & Regards

bretg commented 2 years ago

Thanks for the detailed enhancement description @jbartek25 . For the record, I only reviewed the main PBS repo for issues. Will start looking here every two weeks in prep for the committee meeting.

Anyhow, as is apparent from the lack of response, no, there is no plan to change the fetching of accounts. Community contributions are always welcome, particularly if they're configurable.

We have discussed possibly adding a mode where the server can load a large batch of account data into cache at startup before accepting requests.

bretg commented 1 year ago

@jbartek25 - discussed in committee -- we're open to contributions like this.