Created
          July 20, 2017 09:15 
        
      - 
      
- 
        Save akhy/f949dd5fc099808716e09550eeab7b06 to your computer and use it in GitHub Desktop. 
    gunicorn workers config based on physical cpu
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from sys import platform | |
| if platform == "linux" or platform == "linux2": | |
| from sh import grep, wc, cat | |
| # cat /proc/cpuinfo | grep 'core id' | wc -l | |
| cpu_count = wc(grep(cat('/proc/cpuinfo'), 'core id'), '-l') | |
| elif platform == "darwin": | |
| from sh import grep, sysctl, awk | |
| # sysctl -a | grep machdep.cpu.core_count | awk '{print $2}' | |
| cpu_count = awk(grep(sysctl('-a'), 'machdep.cpu.core_count'), '{print $2}') | |
| if cpu_count: | |
| globals()['workers'] = 2 * int(cpu_count) + 1 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment