Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very high response time for setup licence key api with existing data #994

Open
edubacco opened this issue May 14, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@edubacco
Copy link

馃悰 Bug Report

Hi folks,
I'm encountering response times of around 1 minute when calling the API to set up the license key in my self-hosted SuperTokens instance. This delay coincides with a noticeable increase in CPU usage by the database, the query consuming many resources seems to be

SELECT count(?) as c FROM ( SELECT count(user_id) as num_login_methods, app_id, primary_or_recipe_user_id FROM app_id_to_user_id WHERE primary_or_recipe_user_id IN ( SELECT user_id FROM user_last_active WHERE app_id = $1 AND last_active_time >= $2 ) GROUP BY app_id, primary_or_recipe_user_id) uc WHERE num_login_methods > ?

Useful informations

I'm using this docker image: registry.supertokens.io/supertokens/supertokens-postgresql:9.0

I run the apps inside kubernetes, and AWS RDS aurora postgres database.
I have a paid licence, I use two different tenants connected to two different database instance. I activated roles and account linking. Every tenant has some thousand users.

My setup consists of three scaled instances of SuperTokens core, and three backend instances communicating with the core.
I use different databases per tenant, with one main tenant in one database instance and another tenant in a separate database instance.
Following guide, I configure SuperTokens core via API calls made by the backend application: at every backend startup, I do api calls to the core to inject configs (licence key, tenant configs, and so on).
The set licence call lasts minutes, while other setup api calls answer fast.

It seems a ST issue, can you have a look?

Thanks 馃檹

link to discord chat we had: https://discord.com/channels/603466164219281420/1239606145195184178
cc @rishabhpoddar, @sattvikc

@edubacco edubacco added the bug Something isn't working label May 14, 2024
@sattvikc
Copy link
Collaborator

@edubacco Thank you for pointing out this issue. The fix is a bit complex and it might take a while to implement. Meanwhile, would request you to not have add license key call in the infra code for now. Once the fix is in, you would be notified from this issue and then you can re-add.

@edubacco
Copy link
Author

Thanks for the update @sattvikc, I've already deployed that workaround, I wait for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants