Hosting Directus
When hosting Directus, it's important to know how Directus works. You can then decide on your requirements and meet your budget. This article will cover how Directus utilizes hardware and recommend different hosting options for Directus.
Hosting Directus really depends on the expected traffic or load on the API. It can run easily on a single CPU with 1GB RAM but if your traffic peaks or you have a regular stream of heavy traffic, then it's worth looking at 2 or 4 CPU cores.
I've collected some hosting companies that can run Directus. It's important to read further and find out what resrouces you will need when purchasing a server.
- Liguid Web VPS Hosting
- Namecheap VPS Hosting
- InMotion VPS Hosting (Unmanaged)
- A2 Hosting VPS (Unmanaged)
- BlueHost VPS
- GoDaddy VPS (This link will get you 30% off. To VPS options, click on the website menu, then click All Hosting. Scroll to the options and under VPS click Learn more)
- InterServer VPS
- Hostinger VPS
- eUKhost VPS
Directus also provide their own hosting - Directus Hosting Plans
If you want to read futher into this website hosting in general, Amazon have Web Hosting for Dummies or other web hosting resources.
Shared Hosting, VPS or Dedicated?
Most hosting providers offer Shared Hosting, VPS and Dedicated options. Shared Hosting is not suitable for Directus as the demand on the API can exceed your agreement. Dedicated is the best and will get you the highest performance and bandwidth, but is expensive. VPS is the happy middle-ground.
Introduction
At it's core, Directus has an API that queries your Database whenever someone interacts with the interface. If you have any app or websites, this will also interact with the API and increase the load. When a query is requested, it utilises a CPU core to process the request and return the data. With the Interface written in VueJS 3, the data is rendered using the client's device, taking that pressure away from the server. But, it's never just a single query. Whenever you interact with Directus, there are several queries running in the background, each with their own purpose. With this in mind, how many cores should I have?
How Many Cores Should I have?
A single CPU server will have a bottleneck of all the requests coming through and will ultimately seem slower to a user. Increasing the cores, increases concurrency where requests can be made at the exact same time. Here are my recommendations.
- 1 CPU: Small Project, 1 - 3 users and a low volume website (minimal chance that 2 requests happen at exactly the same time ~30,000)
- 2 CPUs: Medium Project, 4 - 10 users and a medium volume website (~70,000 views per day)
- 4 CPUs: Large Project, 10+ users and a high volume website (~200,000 views per day)
More Cores or Higher Clock Speed?
Hosting providers tend to have decent clocks speeds and the only reason to increase it, is when your scripts are very long or complex. In most cases, increasing the cores is the better way to go and more cost effective.
Should I Decouple my Website to Increase Performance?
In most cases, this wouldn't make much difference since the requests still need to go through Directus. If you have a website that is using another CMS such as Wordpress, then it is definately worth hosting them seperately as they will be competing for computing power.
For example, you can use Wordpress and Kinsta, then have your Directus on another server. Unfortunately Kinsta only support Wordpress.
How Much RAM Do I Need?
RAM comes down to the volume of images you intend to have. Directus creates thumbnails on the fly and requires RAM to create them. The larger the images, the more RAM required to resize them. Here are my recommendations:
- 1GB RAM: Small digital assets always less than 2 MBs
- 2GB RAM: Large digital assets always less than 10 MBs
- 4GB RAM: Photography level digital assets always greater than 10 MBs (requires changes to configration file to support more than 6000px)
- 8GB RAM: Frequently adding new high resolution images
The RAM is also impacted by the CPU. If you have 2 CPU cores, then requests for thumbnails may come at exactly the same time and would need more RAM to complete both requests. Common server specs have twice the RAM per CPU core, for example, 1 CPU 2GB RAM, 2 CPU 4GB RAM.
Enterprise Level
When you reach Enterprise level requirements, this is where Directus can really impress. Hosting become more of a infrastructure diagram with mutiple servers. Companies like AWS, Azure and Google Cloud make this process simpler by giving you all the tools in one place.
In order to load balance Directus, you need to move the SQL database to a central location and use cloud file storage. Most Enterprise hosting companies provide a managed SQL service with load balancing so you don't need to worry about data integrity. Amazon S3, Google Cloud Storage and Azure are supported.
Once you have your SQL credentials, create multiple servers to host the Directus software and your website. Use the information from earlier to decide on the hardware specifications. When installing Directus, add you SQL server credentials. Repeat for all servers. Now you can use Directus on any server and they will always be in sync.
Here is an example of a load balanced infrastructure.
How Many Cores Should I have when load balancing?
It's quite simple. Each time you add a new server, it divides you traffic by the number of servers. Let's say you have 1 million users per day, you can use 5 servers with 4 Cores or 12 servers with 2 cores.
How to Reduce to Cost?
When load balancing servers, this can start to drive up the cost significantly, so how do we reduce the cost? This is where you can start switching servers off during quieter periods. Cloud computing companies offer many "Elastic" services where you can automatically toggle new servers on and off depending on your traffic so you are only paying for what you need.
Conclusion
Now you know how Directus handles requests with the CPU and RAM and how to choose the specifications that work for you. Ready to get started, check out some recommended hosts below.
- Liguid Web VPS Hosting
- Namecheap VPS Hosting
- InMotion VPS Hosting (Unmanaged)
- A2 Hosting VPS
- BlueHost
- GoDaddy VPS (This link will get you 30% off. To VPS options, click on the website menu, then click All Hosting. Scroll to the options and under VPS click Learn more)
- InterServer VPS
- Hostinger VPS
- eUKhost VPS