I know this is a old question. But I think I have a better answer to this question. Gunicorn docs suggests that 2n+1 [gunicorn -w <2n+1> myapp:wsgi
] is a good guess for number of workers (Yes, n = number of cores). I came up with a tiny shell script to apply this formula. All you need to do is this:
gunicorn -w $(( 2 * `cat /proc/cpuinfo | grep 'core id' | wc -l` + 1 )) myapp:wsgi
Where the command
cat /proc/cpuinfo | grep 'core id' | wc -l
will return the total number of actual CPU cores (n). So
$(( 2 * `cat /proc/cpuinfo | grep 'core id' | wc -l` + 1 ))
equates to 2n+1 formula.
This will apply 2n+1 formula to all the linux-based machines. You dont need to know the number of workers for each type of instance or anything like that.
Reference: http://dhilipsiva.com/2015/10/22/appropriate-number-of-gunicorn-workers.html