https://www.growthbook.io/ logo
b

bland-vegetable-68187

10/08/2022, 12:12 AM
Hey guys. I’m starting with the javascript SDK implementation so I can do server side feature flag checking on my expressjs backend. As first shot, I added a new “GrowthBook middleware” that creates and setup a new GrowthBook object context for every request that needs a feature flag check. Can you imagine a better memory-optimized solution for an expressjs backend?
f

fresh-football-47124

10/08/2022, 12:13 AM
Are you caching the feature definitions json?
b

bland-vegetable-68187

10/08/2022, 12:16 AM
Yes, with an in-memory database
f

fresh-football-47124

10/08/2022, 12:17 AM
that should be really fast
b

bland-vegetable-68187

10/08/2022, 12:21 AM
It actually is. Just wondering if someone comes up with something better than calling
new GrowthBook()
in every request
f

future-teacher-7046

10/08/2022, 2:16 AM
There is a
destroy
method you can use at the end of the request to release some memory back. The instances are extremely lightweight. It's technically possible to reuse instances, but usually not worth the complexity.
b

bland-vegetable-68187

10/08/2022, 2:51 AM
Thanks both of you for the fast response.
2 Views