Rails App, Nginx, Virtual Hosts and bandwidth shaping

Anton Yuzhaninov citrin at citrin.ru
Sun Mar 22 22:33:52 MSK 2009

Daniele :) wrote:
> Hi,
> I'm testing a Rails app that serves multiple different sites with a
> virtual hosts configuration under nginx. I need to set a limit
> per host basis so a single site will be unable to eat all the bandwidth
> and
> server resources. Nginx can limit per ip but not per vhost, right?
> Any solution?
> Thank you in advance :)

nginx currently can limit bandwidth only on per-connection basis.

But we can limit rate for each connection, and than limit maximum number of connection to each 
virtual host.

Somethings like:

http {
   limit_rate 250000;
   limit_zone conn_to_server $server_name 10m;

   limit_conn conn_to_server 100;

   server { ... }
   server { ... }
   server { ... }

With this settings each virtualhost can't use more than  250000*100 = 25 Mbit of bandwidth.

  Anton Yuzhaninov

More information about the nginx mailing list