Skip to content

feat: calculate tenant usage in core #7174

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 9, 2025
Merged

Conversation

darcyYe
Copy link
Contributor

@darcyYe darcyYe commented Mar 24, 2025

Summary

Since Logto's services are deployed across different regions (AU, US, EU, etc.), frequent cross-region requests inherently take longer due to physical distance limitations. To reduce the waiting time for systems operating within the same region caused by these prolonged requests, we minimize or replace such requests with alternative approaches wherever possible.

Prior to this change, fetching subscription usage data required frequent cross-region requests to Logto Cloud (hosted in the EU). Now, we compute subscription usage locally within each region (except for tenantMembers, which still necessitates requests to the Logto Cloud service—all other usage metrics can be calculated locally). This optimization significantly improves API performance for services in non-EU regions.

This resolves LOG-10879

Testing

Will be covered with Logto Cloud integration tests, see https://github.com/logto-io/cloud/pull/1180.
In previous https://github.com/logto-io/cloud/pull/1169, we add quota guard logics integration tests for Cloud.

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

@github-actions github-actions bot added the feature Cool stuff label Mar 24, 2025
Copy link

github-actions bot commented Mar 24, 2025

COMPARE TO master

Total Size Diff ⚠️ 📈 +15.74 KB

Diff by File
Name Diff
packages/core/src/libraries/quota.ts 📈 +2.88 KB
packages/core/src/queries/tenant-usage/index.ts 📈 +9.75 KB
packages/core/src/queries/tenant-usage/types.ts 📈 +2.07 KB
packages/core/src/routes/resource.scope.ts 📈 +5 Bytes
packages/core/src/routes/role.scope.ts 📈 +5 Bytes
packages/core/src/routes/sign-in-experience/index.ts 📈 +47 Bytes
packages/core/src/tenants/Libraries.ts 📈 +64 Bytes
packages/core/src/tenants/Queries.ts 📈 +114 Bytes
packages/core/src/test-utils/quota.ts 📈 +927 Bytes

@darcyYe darcyYe force-pushed the yemq-calculate-usage-in-core branch 2 times, most recently from 973f5f1 to f2a78e1 Compare March 27, 2025 08:36
@darcyYe darcyYe marked this pull request as ready for review March 27, 2025 08:36
@darcyYe darcyYe force-pushed the yemq-calculate-usage-in-core branch from f2a78e1 to 78d73fd Compare April 7, 2025 09:02
@darcyYe darcyYe force-pushed the yemq-calculate-usage-in-core branch from b29e6a8 to 3ba5558 Compare April 7, 2025 10:33
@darcyYe darcyYe merged commit bfd21f7 into master Apr 9, 2025
35 checks passed
@darcyYe darcyYe deleted the yemq-calculate-usage-in-core branch April 9, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants