Forum: NGINX Rails App, Nginx, Virtual Hosts and bandwidth shaping

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
53c5e81717521abde3324af483c98af8?d=identicon&s=25 Daniele :) (daniele)
on 2009-03-22 19:31
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 :)

d.
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-03-22 20:48
(Received via mailing list)
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.
53c5e81717521abde3324af483c98af8?d=identicon&s=25 Daniele :) (daniele)
on 2009-03-22 21:20
Anton Yuzhaninov wrote:

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

Wonderful, thank you very much Anton!

Is it possibile to find out when the limit is triggered? I read that
this setup generate a Service unavailable (503), I suppose it's logged
so I can parse the file and fire and alert. Other solutions?

By the way I will prefer a solution that slow down all the requests (I
really dont know how, queue? throttle?) instead of killing them. Is it
possibile?
This topic is locked and can not be replied to.