504 Timeout Using to Many cUrl From Website That is DownConfigure php5-fpm for many concurrent usersOptimizing Web Server(apache2+nginx+memcached+eaccelerator) for high-loaded heavy applicationnginx node.js & socket.io 504 timeout504 gateway timeout after loading several php pages504 Gateway timeout / 502 Bad gateway after installing php curl - server nginxNginX + WordPress + SSL + non-www + W3TC vhost config file questionsChange Nginx document root from /usr/share/nginx to /etc/nginxGot 504 Timeout in 200ms. What does that mean?403 Forbidden nginx (nginx/1.8.0)Periodically 504 timeout with nginx and php-fpm

Would life always name the light from their sun "white"

SHAKE-128/256 or SHA3-256/512

Rushed passport - does my reason qualify?

Why can't I share a one use code with anyone else?

Solenoid fastest possible release - for how long should reversed polarity be applied?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

"Counterexample" for the Inverse function theorem

Why does the U.S military use mercenaries?

Iterate lines of string variable in bash

How was the blinking terminal cursor invented?

Why did the soldiers of the North disobey Jon?

Using a Snow jacket for non snow conditions?

What is the velocity distribution of the exhaust for a typical rocket engine?

Non-African Click Languages

Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?

Why didn't Daenerys' advisers suggest assassinating Cersei?

Can a person still be an Orthodox Jew and believe that the Torah contains narratives that are not scientifically correct?

Promotion comes with unexpected 24/7/365 on-call

What would a Dragon have to exhale to cause rain?

​Cuban​ ​Primes

How can I make dummy text (like lipsum) grey?

Why were the bells ignored in S8E5?

Why does string strummed with finger sound different from the one strummed with pick?

Why did nobody know who the Lord of this region was?



504 Timeout Using to Many cUrl From Website That is Down


Configure php5-fpm for many concurrent usersOptimizing Web Server(apache2+nginx+memcached+eaccelerator) for high-loaded heavy applicationnginx node.js & socket.io 504 timeout504 gateway timeout after loading several php pages504 Gateway timeout / 502 Bad gateway after installing php curl - server nginxNginX + WordPress + SSL + non-www + W3TC vhost config file questionsChange Nginx document root from /usr/share/nginx to /etc/nginxGot 504 Timeout in 200ms. What does that mean?403 Forbidden nginx (nginx/1.8.0)Periodically 504 timeout with nginx and php-fpm






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a dedicated server with 32 gb ram / 8 processors.
I use on all my sites cUrl php displaying some code. The website from where I make the cUrl is a VPS where I use another cUrl with multiple proxies that switches every request.



So I use like this: on site A (Dedicated Server) curl to site B (VPS).
The cUrl code looks like this:



$url = "https://siteB.com/code";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt ($ch, CURLOPT_TIMEOUT, 7);
$curl_res = curl_exec($ch);
curl_close ($ch);


My problem is that on a website (site A in this case) I have like 300k visitors per day and if the site B doesn't respond for any reason the site A gets 504 timeout and the other websites on dedicated server works ok.



On error log from site A I have errors like this:



25329#25329: *3623 upstream timed out (110: Connection timed out) while reading response header from upstream


When I check Nginx I see that from 40-50 writing (that were usually) there are to many writing processes and from here it gets timeout



Active connections: 1756 
server accepts handled requests
11367 11367 11377
Reading: 0 Writing: 1395 Waiting: 361


My nginx configuration is:



worker_processes auto;
worker_rlimit_nofile 65535;

events
multi_accept on;
use epoll;
worker_connections 65535;


http
## Basic Settings ##
client_body_buffer_size 128k;
client_body_timeout 5s; # Use 5s for high-traffic sites
client_header_timeout 5s; # Use 5s for high-traffic sites
client_max_body_size 1024m;
keepalive_timeout 30s;
open_file_cache max=200000 inactive=20s;
open_file_cache_errors on;
open_file_cache_min_uses 2;
open_file_cache_valid 30s;
port_in_redirect off;
reset_timedout_connection on;
send_timeout 5s;
sendfile on;
server_name_in_redirect off;
server_names_hash_bucket_size 1024;
server_names_hash_max_size 1024;
server_tokens off;
tcp_nodelay on;
tcp_nopush on;
types_hash_max_size 2048;

## DNS Resolver ##
# If in China, enable the OpenDNS entry that matches your network connectivity (IPv4 only or IPv4 & IPv6)
# OpenDNS (IPv4 & IPv6)
#resolver 208.67.222.222 208.67.220.220 [2620:0:ccc::2] [2620:0:ccd::2];
# OpenDNS (IPv4 only)
#resolver 208.67.222.222 208.67.220.220;
# Google Public DNS (IPv4 & IPv6)
#resolver 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844];
# Google Public DNS (IPv4 only) [default]
resolver 8.8.8.8 8.8.4.4;

## Real IP Forwarding ##
set_real_ip_from 127.0.0.1;

# CloudFlare IPs
# List from: https://www.cloudflare.com/ips-v4
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
# List from: https://www.cloudflare.com/ips-v6
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2c0f:f248::/32;
set_real_ip_from 2a06:98c0::/29;

# Replace with correct visitor IP
real_ip_header X-Forwarded-For;
real_ip_recursive on;

## MIME ##
include /etc/nginx/mime.types;
default_type application/octet-stream;

## Logging Settings ##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

## Gzip Settings ##
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_min_length 256;
gzip_proxied any;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-javascript
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/javascript
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy
text/x-js
text/xml;
gzip_vary on;

# Security Headers
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;

# Info
add_header X-Nginx-Cache-Status $upstream_cache_status;
add_header X-Server-Powered-By "Engintron";

# Proxy Cache Settings
proxy_cache_path /var/cache/nginx/engintron_dynamic levels=1:2 keys_zone=engintron_dynamic:20m inactive=10m max_size=512m;
proxy_cache_path /var/cache/nginx/engintron_static levels=1:2 keys_zone=engintron_static:20m inactive=10m max_size=512m;
proxy_temp_path /var/cache/nginx/engintron_temp;

## Virtual Host Configs ##
include /etc/nginx/conf.d/*.conf;



What I ask is, how can I make the cUrl check if the website B is slow or down to stop that request if no response in 4-5-6 seconds? Or there is something I can increase in my configuration? I also see that Load Averages doesn't go more than 1.5 (this was the maximum for all the server).



System Status now:



Processors: 8 CPU(s)

RAM: 31.19 GB

Memory Usage:
total used free shared buff/cache available
Mem: 31940 2155 2301 686 27484 28449
Swap: 1021 22 999


From what I see there is a limit somewhere that if the X connections is reached it gets slowed or timeout, but don't know were.



On my Dedicate Server I have all setup configuration to default from WHM Cpanel, except the configuration from nginx.



P.S. I'm not good at all with servers and if can someone guide me.



EDIT



Still one site is down (after modifying the timeout to be the same) and rest are working ok.



This are the connection on my server now:



Active connections: 4382 
server accepts handled requests
457784 457784 478795
Reading: 0 Writing: 4071 Waiting: 310


Usually there are maximum 1000 active connections...










share|improve this question






























    0















    I have a dedicated server with 32 gb ram / 8 processors.
    I use on all my sites cUrl php displaying some code. The website from where I make the cUrl is a VPS where I use another cUrl with multiple proxies that switches every request.



    So I use like this: on site A (Dedicated Server) curl to site B (VPS).
    The cUrl code looks like this:



    $url = "https://siteB.com/code";
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 7);
    curl_setopt ($ch, CURLOPT_TIMEOUT, 7);
    $curl_res = curl_exec($ch);
    curl_close ($ch);


    My problem is that on a website (site A in this case) I have like 300k visitors per day and if the site B doesn't respond for any reason the site A gets 504 timeout and the other websites on dedicated server works ok.



    On error log from site A I have errors like this:



    25329#25329: *3623 upstream timed out (110: Connection timed out) while reading response header from upstream


    When I check Nginx I see that from 40-50 writing (that were usually) there are to many writing processes and from here it gets timeout



    Active connections: 1756 
    server accepts handled requests
    11367 11367 11377
    Reading: 0 Writing: 1395 Waiting: 361


    My nginx configuration is:



    worker_processes auto;
    worker_rlimit_nofile 65535;

    events
    multi_accept on;
    use epoll;
    worker_connections 65535;


    http
    ## Basic Settings ##
    client_body_buffer_size 128k;
    client_body_timeout 5s; # Use 5s for high-traffic sites
    client_header_timeout 5s; # Use 5s for high-traffic sites
    client_max_body_size 1024m;
    keepalive_timeout 30s;
    open_file_cache max=200000 inactive=20s;
    open_file_cache_errors on;
    open_file_cache_min_uses 2;
    open_file_cache_valid 30s;
    port_in_redirect off;
    reset_timedout_connection on;
    send_timeout 5s;
    sendfile on;
    server_name_in_redirect off;
    server_names_hash_bucket_size 1024;
    server_names_hash_max_size 1024;
    server_tokens off;
    tcp_nodelay on;
    tcp_nopush on;
    types_hash_max_size 2048;

    ## DNS Resolver ##
    # If in China, enable the OpenDNS entry that matches your network connectivity (IPv4 only or IPv4 & IPv6)
    # OpenDNS (IPv4 & IPv6)
    #resolver 208.67.222.222 208.67.220.220 [2620:0:ccc::2] [2620:0:ccd::2];
    # OpenDNS (IPv4 only)
    #resolver 208.67.222.222 208.67.220.220;
    # Google Public DNS (IPv4 & IPv6)
    #resolver 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844];
    # Google Public DNS (IPv4 only) [default]
    resolver 8.8.8.8 8.8.4.4;

    ## Real IP Forwarding ##
    set_real_ip_from 127.0.0.1;

    # CloudFlare IPs
    # List from: https://www.cloudflare.com/ips-v4
    set_real_ip_from 103.21.244.0/22;
    set_real_ip_from 103.22.200.0/22;
    set_real_ip_from 103.31.4.0/22;
    set_real_ip_from 104.16.0.0/12;
    set_real_ip_from 108.162.192.0/18;
    set_real_ip_from 131.0.72.0/22;
    set_real_ip_from 141.101.64.0/18;
    set_real_ip_from 162.158.0.0/15;
    set_real_ip_from 172.64.0.0/13;
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 188.114.96.0/20;
    set_real_ip_from 190.93.240.0/20;
    set_real_ip_from 197.234.240.0/22;
    set_real_ip_from 198.41.128.0/17;
    # List from: https://www.cloudflare.com/ips-v6
    set_real_ip_from 2400:cb00::/32;
    set_real_ip_from 2405:8100::/32;
    set_real_ip_from 2405:b500::/32;
    set_real_ip_from 2606:4700::/32;
    set_real_ip_from 2803:f800::/32;
    set_real_ip_from 2c0f:f248::/32;
    set_real_ip_from 2a06:98c0::/29;

    # Replace with correct visitor IP
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;

    ## MIME ##
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ## Logging Settings ##
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ## Gzip Settings ##
    gzip on;
    gzip_buffers 16 8k;
    gzip_comp_level 5;
    gzip_disable "msie6";
    gzip_min_length 256;
    gzip_proxied any;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.geo+json
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-javascript
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/bmp
    image/svg+xml
    image/x-icon
    text/cache-manifest
    text/css
    text/javascript
    text/plain
    text/vcard
    text/vnd.rim.location.xloc
    text/vtt
    text/x-component
    text/x-cross-domain-policy
    text/x-js
    text/xml;
    gzip_vary on;

    # Security Headers
    add_header X-XSS-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;

    # Info
    add_header X-Nginx-Cache-Status $upstream_cache_status;
    add_header X-Server-Powered-By "Engintron";

    # Proxy Cache Settings
    proxy_cache_path /var/cache/nginx/engintron_dynamic levels=1:2 keys_zone=engintron_dynamic:20m inactive=10m max_size=512m;
    proxy_cache_path /var/cache/nginx/engintron_static levels=1:2 keys_zone=engintron_static:20m inactive=10m max_size=512m;
    proxy_temp_path /var/cache/nginx/engintron_temp;

    ## Virtual Host Configs ##
    include /etc/nginx/conf.d/*.conf;



    What I ask is, how can I make the cUrl check if the website B is slow or down to stop that request if no response in 4-5-6 seconds? Or there is something I can increase in my configuration? I also see that Load Averages doesn't go more than 1.5 (this was the maximum for all the server).



    System Status now:



    Processors: 8 CPU(s)

    RAM: 31.19 GB

    Memory Usage:
    total used free shared buff/cache available
    Mem: 31940 2155 2301 686 27484 28449
    Swap: 1021 22 999


    From what I see there is a limit somewhere that if the X connections is reached it gets slowed or timeout, but don't know were.



    On my Dedicate Server I have all setup configuration to default from WHM Cpanel, except the configuration from nginx.



    P.S. I'm not good at all with servers and if can someone guide me.



    EDIT



    Still one site is down (after modifying the timeout to be the same) and rest are working ok.



    This are the connection on my server now:



    Active connections: 4382 
    server accepts handled requests
    457784 457784 478795
    Reading: 0 Writing: 4071 Waiting: 310


    Usually there are maximum 1000 active connections...










    share|improve this question


























      0












      0








      0








      I have a dedicated server with 32 gb ram / 8 processors.
      I use on all my sites cUrl php displaying some code. The website from where I make the cUrl is a VPS where I use another cUrl with multiple proxies that switches every request.



      So I use like this: on site A (Dedicated Server) curl to site B (VPS).
      The cUrl code looks like this:



      $url = "https://siteB.com/code";
      $ch = curl_init();
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 7);
      curl_setopt ($ch, CURLOPT_TIMEOUT, 7);
      $curl_res = curl_exec($ch);
      curl_close ($ch);


      My problem is that on a website (site A in this case) I have like 300k visitors per day and if the site B doesn't respond for any reason the site A gets 504 timeout and the other websites on dedicated server works ok.



      On error log from site A I have errors like this:



      25329#25329: *3623 upstream timed out (110: Connection timed out) while reading response header from upstream


      When I check Nginx I see that from 40-50 writing (that were usually) there are to many writing processes and from here it gets timeout



      Active connections: 1756 
      server accepts handled requests
      11367 11367 11377
      Reading: 0 Writing: 1395 Waiting: 361


      My nginx configuration is:



      worker_processes auto;
      worker_rlimit_nofile 65535;

      events
      multi_accept on;
      use epoll;
      worker_connections 65535;


      http
      ## Basic Settings ##
      client_body_buffer_size 128k;
      client_body_timeout 5s; # Use 5s for high-traffic sites
      client_header_timeout 5s; # Use 5s for high-traffic sites
      client_max_body_size 1024m;
      keepalive_timeout 30s;
      open_file_cache max=200000 inactive=20s;
      open_file_cache_errors on;
      open_file_cache_min_uses 2;
      open_file_cache_valid 30s;
      port_in_redirect off;
      reset_timedout_connection on;
      send_timeout 5s;
      sendfile on;
      server_name_in_redirect off;
      server_names_hash_bucket_size 1024;
      server_names_hash_max_size 1024;
      server_tokens off;
      tcp_nodelay on;
      tcp_nopush on;
      types_hash_max_size 2048;

      ## DNS Resolver ##
      # If in China, enable the OpenDNS entry that matches your network connectivity (IPv4 only or IPv4 & IPv6)
      # OpenDNS (IPv4 & IPv6)
      #resolver 208.67.222.222 208.67.220.220 [2620:0:ccc::2] [2620:0:ccd::2];
      # OpenDNS (IPv4 only)
      #resolver 208.67.222.222 208.67.220.220;
      # Google Public DNS (IPv4 & IPv6)
      #resolver 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844];
      # Google Public DNS (IPv4 only) [default]
      resolver 8.8.8.8 8.8.4.4;

      ## Real IP Forwarding ##
      set_real_ip_from 127.0.0.1;

      # CloudFlare IPs
      # List from: https://www.cloudflare.com/ips-v4
      set_real_ip_from 103.21.244.0/22;
      set_real_ip_from 103.22.200.0/22;
      set_real_ip_from 103.31.4.0/22;
      set_real_ip_from 104.16.0.0/12;
      set_real_ip_from 108.162.192.0/18;
      set_real_ip_from 131.0.72.0/22;
      set_real_ip_from 141.101.64.0/18;
      set_real_ip_from 162.158.0.0/15;
      set_real_ip_from 172.64.0.0/13;
      set_real_ip_from 173.245.48.0/20;
      set_real_ip_from 188.114.96.0/20;
      set_real_ip_from 190.93.240.0/20;
      set_real_ip_from 197.234.240.0/22;
      set_real_ip_from 198.41.128.0/17;
      # List from: https://www.cloudflare.com/ips-v6
      set_real_ip_from 2400:cb00::/32;
      set_real_ip_from 2405:8100::/32;
      set_real_ip_from 2405:b500::/32;
      set_real_ip_from 2606:4700::/32;
      set_real_ip_from 2803:f800::/32;
      set_real_ip_from 2c0f:f248::/32;
      set_real_ip_from 2a06:98c0::/29;

      # Replace with correct visitor IP
      real_ip_header X-Forwarded-For;
      real_ip_recursive on;

      ## MIME ##
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      ## Logging Settings ##
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;

      ## Gzip Settings ##
      gzip on;
      gzip_buffers 16 8k;
      gzip_comp_level 5;
      gzip_disable "msie6";
      gzip_min_length 256;
      gzip_proxied any;
      gzip_types
      application/atom+xml
      application/javascript
      application/json
      application/ld+json
      application/manifest+json
      application/rss+xml
      application/vnd.geo+json
      application/vnd.ms-fontobject
      application/x-font-ttf
      application/x-javascript
      application/x-web-app-manifest+json
      application/xhtml+xml
      application/xml
      font/opentype
      image/bmp
      image/svg+xml
      image/x-icon
      text/cache-manifest
      text/css
      text/javascript
      text/plain
      text/vcard
      text/vnd.rim.location.xloc
      text/vtt
      text/x-component
      text/x-cross-domain-policy
      text/x-js
      text/xml;
      gzip_vary on;

      # Security Headers
      add_header X-XSS-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;

      # Info
      add_header X-Nginx-Cache-Status $upstream_cache_status;
      add_header X-Server-Powered-By "Engintron";

      # Proxy Cache Settings
      proxy_cache_path /var/cache/nginx/engintron_dynamic levels=1:2 keys_zone=engintron_dynamic:20m inactive=10m max_size=512m;
      proxy_cache_path /var/cache/nginx/engintron_static levels=1:2 keys_zone=engintron_static:20m inactive=10m max_size=512m;
      proxy_temp_path /var/cache/nginx/engintron_temp;

      ## Virtual Host Configs ##
      include /etc/nginx/conf.d/*.conf;



      What I ask is, how can I make the cUrl check if the website B is slow or down to stop that request if no response in 4-5-6 seconds? Or there is something I can increase in my configuration? I also see that Load Averages doesn't go more than 1.5 (this was the maximum for all the server).



      System Status now:



      Processors: 8 CPU(s)

      RAM: 31.19 GB

      Memory Usage:
      total used free shared buff/cache available
      Mem: 31940 2155 2301 686 27484 28449
      Swap: 1021 22 999


      From what I see there is a limit somewhere that if the X connections is reached it gets slowed or timeout, but don't know were.



      On my Dedicate Server I have all setup configuration to default from WHM Cpanel, except the configuration from nginx.



      P.S. I'm not good at all with servers and if can someone guide me.



      EDIT



      Still one site is down (after modifying the timeout to be the same) and rest are working ok.



      This are the connection on my server now:



      Active connections: 4382 
      server accepts handled requests
      457784 457784 478795
      Reading: 0 Writing: 4071 Waiting: 310


      Usually there are maximum 1000 active connections...










      share|improve this question
















      I have a dedicated server with 32 gb ram / 8 processors.
      I use on all my sites cUrl php displaying some code. The website from where I make the cUrl is a VPS where I use another cUrl with multiple proxies that switches every request.



      So I use like this: on site A (Dedicated Server) curl to site B (VPS).
      The cUrl code looks like this:



      $url = "https://siteB.com/code";
      $ch = curl_init();
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 7);
      curl_setopt ($ch, CURLOPT_TIMEOUT, 7);
      $curl_res = curl_exec($ch);
      curl_close ($ch);


      My problem is that on a website (site A in this case) I have like 300k visitors per day and if the site B doesn't respond for any reason the site A gets 504 timeout and the other websites on dedicated server works ok.



      On error log from site A I have errors like this:



      25329#25329: *3623 upstream timed out (110: Connection timed out) while reading response header from upstream


      When I check Nginx I see that from 40-50 writing (that were usually) there are to many writing processes and from here it gets timeout



      Active connections: 1756 
      server accepts handled requests
      11367 11367 11377
      Reading: 0 Writing: 1395 Waiting: 361


      My nginx configuration is:



      worker_processes auto;
      worker_rlimit_nofile 65535;

      events
      multi_accept on;
      use epoll;
      worker_connections 65535;


      http
      ## Basic Settings ##
      client_body_buffer_size 128k;
      client_body_timeout 5s; # Use 5s for high-traffic sites
      client_header_timeout 5s; # Use 5s for high-traffic sites
      client_max_body_size 1024m;
      keepalive_timeout 30s;
      open_file_cache max=200000 inactive=20s;
      open_file_cache_errors on;
      open_file_cache_min_uses 2;
      open_file_cache_valid 30s;
      port_in_redirect off;
      reset_timedout_connection on;
      send_timeout 5s;
      sendfile on;
      server_name_in_redirect off;
      server_names_hash_bucket_size 1024;
      server_names_hash_max_size 1024;
      server_tokens off;
      tcp_nodelay on;
      tcp_nopush on;
      types_hash_max_size 2048;

      ## DNS Resolver ##
      # If in China, enable the OpenDNS entry that matches your network connectivity (IPv4 only or IPv4 & IPv6)
      # OpenDNS (IPv4 & IPv6)
      #resolver 208.67.222.222 208.67.220.220 [2620:0:ccc::2] [2620:0:ccd::2];
      # OpenDNS (IPv4 only)
      #resolver 208.67.222.222 208.67.220.220;
      # Google Public DNS (IPv4 & IPv6)
      #resolver 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844];
      # Google Public DNS (IPv4 only) [default]
      resolver 8.8.8.8 8.8.4.4;

      ## Real IP Forwarding ##
      set_real_ip_from 127.0.0.1;

      # CloudFlare IPs
      # List from: https://www.cloudflare.com/ips-v4
      set_real_ip_from 103.21.244.0/22;
      set_real_ip_from 103.22.200.0/22;
      set_real_ip_from 103.31.4.0/22;
      set_real_ip_from 104.16.0.0/12;
      set_real_ip_from 108.162.192.0/18;
      set_real_ip_from 131.0.72.0/22;
      set_real_ip_from 141.101.64.0/18;
      set_real_ip_from 162.158.0.0/15;
      set_real_ip_from 172.64.0.0/13;
      set_real_ip_from 173.245.48.0/20;
      set_real_ip_from 188.114.96.0/20;
      set_real_ip_from 190.93.240.0/20;
      set_real_ip_from 197.234.240.0/22;
      set_real_ip_from 198.41.128.0/17;
      # List from: https://www.cloudflare.com/ips-v6
      set_real_ip_from 2400:cb00::/32;
      set_real_ip_from 2405:8100::/32;
      set_real_ip_from 2405:b500::/32;
      set_real_ip_from 2606:4700::/32;
      set_real_ip_from 2803:f800::/32;
      set_real_ip_from 2c0f:f248::/32;
      set_real_ip_from 2a06:98c0::/29;

      # Replace with correct visitor IP
      real_ip_header X-Forwarded-For;
      real_ip_recursive on;

      ## MIME ##
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      ## Logging Settings ##
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;

      ## Gzip Settings ##
      gzip on;
      gzip_buffers 16 8k;
      gzip_comp_level 5;
      gzip_disable "msie6";
      gzip_min_length 256;
      gzip_proxied any;
      gzip_types
      application/atom+xml
      application/javascript
      application/json
      application/ld+json
      application/manifest+json
      application/rss+xml
      application/vnd.geo+json
      application/vnd.ms-fontobject
      application/x-font-ttf
      application/x-javascript
      application/x-web-app-manifest+json
      application/xhtml+xml
      application/xml
      font/opentype
      image/bmp
      image/svg+xml
      image/x-icon
      text/cache-manifest
      text/css
      text/javascript
      text/plain
      text/vcard
      text/vnd.rim.location.xloc
      text/vtt
      text/x-component
      text/x-cross-domain-policy
      text/x-js
      text/xml;
      gzip_vary on;

      # Security Headers
      add_header X-XSS-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;

      # Info
      add_header X-Nginx-Cache-Status $upstream_cache_status;
      add_header X-Server-Powered-By "Engintron";

      # Proxy Cache Settings
      proxy_cache_path /var/cache/nginx/engintron_dynamic levels=1:2 keys_zone=engintron_dynamic:20m inactive=10m max_size=512m;
      proxy_cache_path /var/cache/nginx/engintron_static levels=1:2 keys_zone=engintron_static:20m inactive=10m max_size=512m;
      proxy_temp_path /var/cache/nginx/engintron_temp;

      ## Virtual Host Configs ##
      include /etc/nginx/conf.d/*.conf;



      What I ask is, how can I make the cUrl check if the website B is slow or down to stop that request if no response in 4-5-6 seconds? Or there is something I can increase in my configuration? I also see that Load Averages doesn't go more than 1.5 (this was the maximum for all the server).



      System Status now:



      Processors: 8 CPU(s)

      RAM: 31.19 GB

      Memory Usage:
      total used free shared buff/cache available
      Mem: 31940 2155 2301 686 27484 28449
      Swap: 1021 22 999


      From what I see there is a limit somewhere that if the X connections is reached it gets slowed or timeout, but don't know were.



      On my Dedicate Server I have all setup configuration to default from WHM Cpanel, except the configuration from nginx.



      P.S. I'm not good at all with servers and if can someone guide me.



      EDIT



      Still one site is down (after modifying the timeout to be the same) and rest are working ok.



      This are the connection on my server now:



      Active connections: 4382 
      server accepts handled requests
      457784 457784 478795
      Reading: 0 Writing: 4071 Waiting: 310


      Usually there are maximum 1000 active connections...







      nginx apache-2.4 php-fpm






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 12 at 20:46







      vezeCS

















      asked May 5 at 14:48









      vezeCSvezeCS

      11




      11




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You set send_timeout (and several other timeouts) to 5 seconds, but your PHP code that calls the external web site waits up to 7 seconds for it to respond. Obviously this won't work. You need to change one or both.






          share|improve this answer























          • Changed now to have same same value as the cUrl. Will get back with results.

            – vezeCS
            May 5 at 19:09











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "2"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f965950%2f504-timeout-using-to-many-curl-from-website-that-is-down%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You set send_timeout (and several other timeouts) to 5 seconds, but your PHP code that calls the external web site waits up to 7 seconds for it to respond. Obviously this won't work. You need to change one or both.






          share|improve this answer























          • Changed now to have same same value as the cUrl. Will get back with results.

            – vezeCS
            May 5 at 19:09















          1














          You set send_timeout (and several other timeouts) to 5 seconds, but your PHP code that calls the external web site waits up to 7 seconds for it to respond. Obviously this won't work. You need to change one or both.






          share|improve this answer























          • Changed now to have same same value as the cUrl. Will get back with results.

            – vezeCS
            May 5 at 19:09













          1












          1








          1







          You set send_timeout (and several other timeouts) to 5 seconds, but your PHP code that calls the external web site waits up to 7 seconds for it to respond. Obviously this won't work. You need to change one or both.






          share|improve this answer













          You set send_timeout (and several other timeouts) to 5 seconds, but your PHP code that calls the external web site waits up to 7 seconds for it to respond. Obviously this won't work. You need to change one or both.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 5 at 15:05









          Michael HamptonMichael Hampton

          177k27322655




          177k27322655












          • Changed now to have same same value as the cUrl. Will get back with results.

            – vezeCS
            May 5 at 19:09

















          • Changed now to have same same value as the cUrl. Will get back with results.

            – vezeCS
            May 5 at 19:09
















          Changed now to have same same value as the cUrl. Will get back with results.

          – vezeCS
          May 5 at 19:09





          Changed now to have same same value as the cUrl. Will get back with results.

          – vezeCS
          May 5 at 19:09

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f965950%2f504-timeout-using-to-many-curl-from-website-that-is-down%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020