flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

Move the Environment DynamoDB document builder to an async task

Open dabeeeenster opened this issue 3 years ago • 6 comments
trafficstars

Against our Flagsmith Website project - trying to override a feature with segment

dabeeeenster avatar Jan 26 '22 20:01 dabeeeenster

I am not able to reproduce this in production.

image

@dabeeeenster can you provide a project / environment / feature where you are able to consistently reproduce please?

matthewelwell avatar Jan 28 '22 11:01 matthewelwell

To update here, I was able to reproduce this only in our Flagsmith Website project but I am able to consistently reproduce it for all feature / segment combinations in this project. I am going to implement some functionality to allow us to force a sentry trace on given endpoints.

matthewelwell avatar Jan 28 '22 12:01 matthewelwell

After enabling the sentry tracing stuff discussed above, this trace should give us the information we're looking for:

https://sentry.io/organizations/flagsmith/performance/flagsmith-api:897e88964e5c4[…]Fv1%2Ffeatures%2Ffeature-segments%2F&unselectedSeries=p100%28%29

There are an awful lot of queries happening in that trace (and that's only on staging).

matthewelwell avatar Jan 28 '22 17:01 matthewelwell

Interestingly, just creating a feature looks like it has the same issue. There's something happening after a request to create an entity in our database which is spawning ~200 additional queries.

https://sentry.io/organizations/flagsmith/performance/flagsmith-api:9ab79b5f71e94d3e9145b2859bbb42b3

matthewelwell avatar Jan 28 '22 18:01 matthewelwell

Ok, it seems like the probable cause of this is the data transfer to dynamo db. A quick test turning off 'enable dynamo db' for one of my projects reduces the number of queries needed to create a feature from 310 -> 50 (although 50 is still insanely high!).

matthewelwell avatar Jan 31 '22 17:01 matthewelwell

This has now been improved but will leave this open as we need to move the Environment document builder to an async task

dabeeeenster avatar Feb 07 '22 14:02 dabeeeenster

This has been moved to a hook on the AuditLog object in Gagan's PR #2179 and AuditLog records are written asynchronously so maybe this is complete as part of that.

matthewelwell avatar May 15 '23 09:05 matthewelwell