If I have two server block in an Nginx and they both use the same upstream definitions. How would the max_conns limit work in this case?
I am assuming that the both server blocks will have a limit of 100 max connections and 90 keepalive. So in total, the following server blocks can have a total of 200 max_conns?
upstream example {
server example.com:443 max_conns=100;
keepalive 90;
}
server {
listen 1.1.1.1:80;
server_name proxy.site.net;
proxy_pass https://example
proxy_bind 1.1.1.1 transparent;
}
server {
listen 1.1.1.2:80;
server_name proxy.site.net;
proxy_pass https://example
proxy_bind 1.1.1.2 transparent;
}
My origin has a restriction of 100 concurrent connections per IP. So, I am splitting the traffic by using different IP for each server block. So, I want to achieve 100 concurrent connections per server block (or per public IP). How should I do that?
The purpose of having two server block is to be able to handle double amount of requests.
UPDATE:
The origin is a cloud provider which has put some hard limits on "connections per IP" in order to avoid overload. The origin says that every IP address can have up to 100 concurrent HTTP connections. If the same IP tries to establish connection number 101, the origin would throw an error. So, I want to use two IPs to have the capability to establish 200 concurrent connections to the origin at a time. Please help if you know what should be changed in my code to achieve it. –
UPDATE 2:
Below is the latest code that I am using to achieve 200 requests per second by using DNS round robin on my server's public IPs.
I have two different IPs listening in two server blocks and two different upstream names for those server blocks.
I am assuming now that If 100 people use the first IP in the DNS round-robin and the next 100 use the second IP then I will be able to serve 200 people concurrently. Even though my origin has a restriction of 100 connections per IP.
Please let me know if this code looks right?
upstream example {
server example.com:443 max_conns=100;
keepalive 90;
}
upstream example2 {
server example.com:443 max_conns=100;
keepalive 90;
}
server {
listen 1.1.1.1:80;
server_name proxy.site.net;
proxy_pass https://example
proxy_bind 1.1.1.1 transparent;
}
server {
listen 1.1.1.2:80;
server_name proxy.site.net;
proxy_pass https://example2
proxy_bind 1.1.1.2 transparent;
}