https://www.growthbook.io/ logo
#announcements
Title
# announcements
r

rhythmic-chef-84815

06/29/2023, 8:11 AM
It looks like I am having some issues with horizontal scaling with the new SDK, I am migrating from webhooks to the new SDK. When I test locally everything seems to be working fine but when we deployed to one of our environments the features are not getting updated there, I can not tell why except that we have multiple BE instances. Does the SDK supports this?
f

fresh-football-47124

06/29/2023, 3:40 PM
BE?
b

better-magician-65629

06/29/2023, 5:40 PM
i assume backend
r

rhythmic-chef-84815

06/30/2023, 8:07 AM
Yes, exactly
b

better-magician-65629

07/04/2023, 5:27 PM
which SDK are you using? if you have multiple backend instances, you'll likely need a caching layer like redis in front of it, since it's likely the features are being cached in-memory on the specific instance when they're updating. if you're using ruby, this example uses the rails cache (which has a redis strategy but this example is using memcache). there's also a GBFeaturesRepository for ruby, the example wasn't updated yet to use it though, but if you wanted to, in the rails cache block you can implement the
Growthbook::FeatureRepository#fetch
call. if you're using java, there's a method on the GBFeaturesRepository#onFeaturesRefresh that you can use to listen to updates to update your shared cache. in the javascript SDK, there doesn't seem to be a way to subscribe to feature updates but i'll check with the rest of the team to confirm.
r

rhythmic-chef-84815

07/06/2023, 7:31 AM
We use javascript and I did look for a method exactly as you said and could not find
So far I am not removing the webhook implementation, that one is working for us just fine so far but I wanted to since it is deprecated. But until I am sure it will work for us as the webhooks did I can not do the migration
@better-magician-65629 could we try to follow up on this topic here again?
f

fresh-football-47124

08/22/2023, 9:11 AM
its very early for Tina, will take some time for her to respond.
r

rhythmic-chef-84815

08/22/2023, 9:28 AM
no worries we can do this async, I just want to continue the conversation 🙂
b

better-magician-65629

08/22/2023, 5:10 PM
since you're using the JS SDK, you may be able to take advantage of the SSE implementation for feature refreshing. you'll need the proxy for this on self-hosted – "_*Streaming* - Updates your application in real-time as features are changed or toggled in GrowthBook (Javascript and React only)_" (looks like our docs are out of date, java also supports SSE) .. all connected clients should get instant updates for feature refreshes. are you using SSE and experiencing issues? in the JS SDK there isn't currently a way to subscribe to feature updates with a callback.
we may not be auto-polyfilling yet, so in node.js you'll need to polyfill eventsource (docs) and use the autoRefresh option:
Copy code
await gb.loadFeatures({ autoRefresh: true });
r

rhythmic-chef-84815

08/24/2023, 7:43 AM
I already had the autoRefresh as true
Copy code
constructor(
    @Inject(AB_TESTING_OPTIONS) private options: ABTestingOptions,
    private abTestingIntegrationService: ABTestingIntegrationService,
    private logger: LoggerService
  ) {
    logger.setContext(ABTestingService.name);

    setPolyfills({
      // Required for Node 17 or earlier
      fetch: fetch,
      EventSource: EventSource
    });

    this.growthbook = new GrowthBook({
      apiHost: '<https://cdn.growthbook.io>',
      clientKey: this.options.growthbookSdkKey,
      enableDevMode: true,
      trackingCallback: this.trackingCallback.bind(this)
    });
  }

  public async onApplicationBootstrap() {
    await this.growthbook.loadFeatures({
      autoRefresh: true,
      timeout: 2000
    });
  }
basically when one of our instances bootstraps it will load the features with autoRefresh: true, or at least it should
but when debugging I saw that not all of them were getting updated
8 Views