flagsmith
flagsmith copied to clipboard
Move the Environment DynamoDB document builder to an async task
Against our Flagsmith Website project - trying to override a feature with segment
I am not able to reproduce this in production.

@dabeeeenster can you provide a project / environment / feature where you are able to consistently reproduce please?
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.
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).
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
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!).
This has now been improved but will leave this open as we need to move the Environment document builder to an async task
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.