title: Nginx 504 Timeout Error within Docker container running Django and loading Scikit-learn model into memory
body: <p>I'm building a web app with Django that uses a pre-trained scikit-learn model to process data that an user inputs through a web form. During development I'm able to load the model into memory by running the following command in urls.py</p>
  
  <pre><code>modelRF = joblib.load('model.pkl')
  </code></pre>
  
  <p>However, when I try to deploy the app inside a Docker container I receive a 504 Gateway Timeout Error. I've tried increasing the timeout limits in the nginx.conf file without any success. I was wondering whether this could also be a problem with the amount of memory assigned to the container.</p>
  
  <p>I'm not sure whether the problem is related to Docker or to the way I'm loading the model into memory while in deployment (rather than in development). I'm using docker-compose with nginx, supervisor and uwsgi.</p>
  
  <p>My nginx.conf file looks like this:</p>
  
  <pre><code>upstream django {
      server unix:///tmp/uwsgi.sock; # for a file socket
  }
  
  server {
      listen      80 default_server;
  
      server_name .example.com;
      charset     utf-8;
  
      # max upload size
      client_max_body_size 75M;   
  
      # Django media
      location /media  {
          alias /home/docker/code/media;
      }
  
      location /static {
         alias /home/docker/code/static;
      }
  
      location / {
          uwsgi_pass  django;
          include /home/docker/code/uwsgi_params; 
      }
  }
  </code></pre>