Load Balancer

The current spree productive system uses an nginx web server to provide faster access to static content and share the load between up to 15 application server (processors).

The setup of the nginx web server is pretty simple and described here.

The current configuration of the nginx web server is as follows:

user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       conf/mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    #gzip  on;

    upstream spree{
        server 127.0.0.1:8080;
        server 127.0.0.1:8081;
        server 127.0.0.1:8082;
        server 127.0.0.1:8083;
        server 127.0.0.1:8084;
        server 127.0.0.1:8085;
        server 127.0.0.1:8086;
        server 127.0.0.1:8087;
        server 127.0.0.1:8088;
        server 127.0.0.1:8089;
        server 127.0.0.1:8090;
        server 127.0.0.1:8091;
        server 127.0.0.1:8092;
        server 127.0.0.1:8093;
        server 127.0.0.1:8094;
        server 127.0.0.1:8095;
    }
    server {
        listen       80;
        server_name  localhost;

        #access_log  logs/host.access.log  main;
        location ^~ /static/  {
                       root /path/to/spree;
        }
        location = /favicon.ico  {
                root /path/to/spree/static/images;
        }
        
        # proxy to turbogears app
        location / {
            proxy_pass              http://spree;
            proxy_redirect          off;
            proxy_set_header        Host $host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

Requests are forwarded to the ports 8080..8095 on localhost. All static content is served directly.