Directus itself is a NodeJS-based API server. The TPS it can support depends on multiple factors such as the database system and API query design. This article provides some architectural considerations to enable Directus applications to scale with business growth by adding hardware, thereby improving system processing capacity and achieving good scalability in performance.
1. How to Plan a Scalable Directus Application
Directus focuses on two aspects for handling high load scenarios:
- Horizontally scaling application servers (deploying multiple Directus instances)
- Using high-performance database solutions, such as Amazon Aurora or CockroachDB
Rijk van Zanten: That being said, I do highly recommend horizontally scaling your Directus instance if you’re planning on running it at scale. Make sure you use Redis for caches / rate limiter, and S3 or another shared file storage for the file storage. At that point, the bottleneck will become the amount of allowed connections and the overall server performance of the database. That being said, there’s a lot of database services nowadays that scale virtually endless, like Amazon Aurora or CockroachDB.
2. Horizontal Scaling of Application Servers
For horizontal scaling, it’s important to note that data shared between all instances cannot be stored locally. Instead, use high-performance solutions like CDN or Redis. Shared data across instances includes: images, files, caches, etc.
Directus uses JWT, so there’s no session sharing issue. It doesn’t matter which instance handles each API request since instances don’t store user state information.
3. Database Scalability
Currently, Directus version 9.5 supports CockroachDB using the PostgreSQL driver. CockroachDB, a fully distributed database, is a revolutionary product that greatly enhances system scalability.
For example, deploying CockroachDB nodes in multiple countries’ IDCs, after networking, each country can access separately. This can:
- Increase database processing bandwidth
- Introduce multi-city, multi-IDC to improve disaster recovery and backup capabilities
- Overseas users can access the database locally, and API servers deployed in overseas data centers reduce access latency
We will continue to monitor the production usage and testing of Directus and CockroachDB.