title: Serving High Traffic Video Over Nginx
body: <p>I am trying to serve a single High-Res video to 30+ clients <em>exactly concurrently</em>. This is leading to a bottle-neck causing some clients to time-out, and some to experience considerable lag.</p>
  
  <p>Right now – it is clear that each individual request is being processed separately so the server is sending many gigs/sec. Someone mentioned it may be possible to configure Nginx to recognize that the requests are all for the same asset, serve it once, and then let the router (we are running this server locally) send the file to all the devices.</p>
  
  <p>Is this feasible and/or is there any other way to increase my throughput?</p>
  
  <p>Here's my conig per request. It's very simple so far...</p>
  
  <pre><code>    upstream unicorn {
        server unix:/tmp/unicorn.todo.sock fail_timeout=0;
      }
  
      server {
          listen 80 default;
          root    /usr/local/var/rails/todo-after/public;
  
          try_files $uri/index.html $uri $uri/video @unicorn;
          location @unicorn {
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $http_host;
              proxy_redirect off;
              proxy_pass http://unicorn;
          }
  
          error_page 500 502 503 504 /500.html;
          client_max_body_size 4G;
          keepalive_timeout 10;
      }
  </code></pre>