Scalability - SuperTokens Docs

Scalability

Learn how SuperTokens scales to handle millions of users and requests efficiently.

Overview

The following page addresses how the SuperTokens components scale based on different factors.


Users and tenants

SuperTokens can handle 10s of millions of users and tenants.
In fact, you can even make one tenant per user and it would work well.
For most operations, the database structure and queries allow partitioning based on tenants and users.
As the number of tenants scales, it does not affect performance on most operations per tenant. Similarly, as the number of users scales, it does not affect performance on most operations per user.


SuperTokens core

The SuperTokens core service supports horizontal scalability.
This means that you can add more instances of the core service to handle more requests.
The core service is also stateless, which means that you can add or remove instances without worrying about the state of the system.

The core service can handle a high number of requests per second (RPS).
The exact number of requests per second (RPS) that the core service can handle depends on the hardware you are using. In general, the core service can manage many requests.

For example, the average latency of requests is ~40 milliseconds at 100-150 requests per second (6,000-10,000 requests per minute).
The compute deployed is 6 instances of the SuperTokens core service, each on a t3.micro EC2 instance behind a round robin load balancer. The CPU usage of each instance is around 10%.

The scale of end users that this can support is in the order of 1-2 million monthly active users, with a total user count of millions more.

Average latency over 1 day

Number of requests per minute over 1 day

Performance tuning

If you are facing performance issues, here are some tips to help you tune the performance of your SuperTokens setup:


Database

SuperTokens works with PostgreSQL databases, and one instance of the database is enough to handle tens of millions of MAUs.
For example, a database with 1 million users would occupy ~ 1.5 GB of disk space (assuming you add minimal custom metadata to the user object).


Backend SDK

The backend SDK does not store any information on its own.
It’s a “big middleware” between the frontend requests and the SuperTokens core.
As such, its scalability depends entirely on the scalability of your API layer into which the backend SDK integrates.


Session verification

The access token is a JWT, and the backend SDK verifies them without any network requests, making them fast and scalable.
The core service verifies the refresh token, and the scalability of session refresh requests depends on the core service’s scalability. However, session refreshes are rare compared to access token verification.