Is it better to split the different components of a stack over several smaller machines or get 1 or 2 bigger machines and put several components on a same machine?
My thought is that if I start with several machines, it will be easier to scale by increasing the power of each machine when needed. I am not ready for horizontal scaling anyway for now.
I have a budget of $20/month to start.
I chose DigitalOcean because it looks flexible with their 512MB droplet so here are my options:
1, 2, 3 or 4 Machines of 512MB
2 Machines of 1GB
1 Machine of 2GB
1 or 2 Machines of 512MB + 1 Machine of 1GB
Here is my stack:
Nginx
+
Gunicorn with 3 workers (=4 processes, memory footprint: ~50MB/process)
+
3 or 4 RQ workers (memory footprint of each worker: ~50MB)
+
Redis as Cache (limit to 100MB to start)
+
Redis as DataStore (small size: it is not meant to store a lot of data, mainly used to store the queues for the workers)
+
PostgreSQL (not sure how much RAM I would need)
The main drawback I see of using several small machines is that since the OS is installed on each machine, each machine has a set of resource dedicated to the OS which is "lost" for the application. The main advantage I see is that it looks easier to scale vertically since each machine can be upgraded separately.
What would be a good trade-off?
Option 1
512MB: Nginx, Gunicorn, Redis Cache
512MB: RQ Workers, Redis DataStore
1GB or 512MB: PostgreSQL
I am not sure whether it's worth it to give 1GB for PostgreSQL only... Maybe I should just use a 512MB droplet as well? Also, I am wondering whether the 512MB machine with Nginx, Gunicorn and the Redis cache would not be too small.
So I could do that:
Option 2
1GB: Nginx, Gunicorn, Redis Cache
512MB: RQ Workers, Redis DataStore
512MB: PostgreSQL
Option 3 using 2 bigger machines
1GB: Nginx, Gunicorn, (RQ Workers), Redis Cache, (Redis DataStore)
1GB or 512MB: PostgreSQL, (RQ Workers here?), (Redis DataStore here?)