Redirect to domain TTFB very slow

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Redirect to domain TTFB very slow

vedranf
Hi

On my Nginx server i use a domain "domain.com" and i have all files here:

/home/nginxs/domains/mydomain.com/public


There i have a folder named "gadgets" and i have some files there and i use
a redirect to another domain for this folder.

So if a user types seconddomain.com it goes to the folder gadgets in the
first domains folder and get al results.....

The problem is that is very slow (first domain is loading super fast !) and
then checking i found this :

So Time to first byte is very slow 6 seconds :(

No idea how can fix this :(

And i can't move that folder to the new created account that i redirect as
the files inside gadgets are interacting with other files there from main
account.....

second domain config:

server {
  listen 80;
  server_name mydomain.com;
  return 301 $scheme://www.mydomain.com$request_uri;
}
server {
  listen 80;
  server_name blog.mydomain.com;
  root /home/nginx/domains/firstdomain/public/blog;
  index index.php;
  access_log /var/log/nginx/blog.gogadget.gr_access.log;
  error_log /var/log/nginx/blog.gogadget.gr_error.log;
  location / {
    try_files $uri $uri/ /index.html /index.php?$args;
  }
}
server {
  listen 80;
  server_name www.mydomain.com dev.mydomain.com;
  root /home/nginx/domains/firstdomain.com/public;
  index index.php;
  access_log /var/log/nginx/mydomain.com_access.log;
  error_log /var/log/nginx/mydomain.com_error.log;
location /go {
  return 301 http://www.mydomain.com/;
}
  location / {
    try_files $uri $uri/ /index.html /index.php?$args;
  }
  location /blog/ {
    deny all;
  }
error_page 500 502 504 /500.html;
  location ~*
^.+\.(?:css|cur|js|jpg|jpeg|gif|ico|png|html|xml|zip|rar|mp4|3gp|flv|webm|f4v|ogm)$
{
    access_log off;
    expires 30d;
    tcp_nodelay off;
    open_file_cache max=3000 inactive=120s;
    open_file_cache_valid 45s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
  }
  location /api2/ {
    rewrite ^/api2/(.*)$ /api/public/index.php?route=$1 last;
  }
  location ~* /(uploads|public)/ {
    access_log off;
    expires 30d;
  }
  location ~ /\.ht {
    deny all;
  }
  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  include /usr/local/nginx/conf/block.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
}

Any ideas?

I am using ZendOpcache and Memcached...

Thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255913,255913#msg-255913

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

Steve Holdoway
On Tue, 2014-12-30 at 18:34 -0500, ASTRAPI wrote:

> Hi
>
> On my Nginx server i use a domain "domain.com" and i have all files here:
>
> /home/nginxs/domains/mydomain.com/public
>
>
> There i have a folder named "gadgets" and i have some files there and i use
> a redirect to another domain for this folder.
>
> So if a user types seconddomain.com it goes to the folder gadgets in the
> first domains folder and get al results.....
>
> The problem is that is very slow (first domain is loading super fast !) and
> then checking i found this :
>
> So Time to first byte is very slow 6 seconds :(
>
> No idea how can fix this :(
>
> And i can't move that folder to the new created account that i redirect as
> the files inside gadgets are interacting with other files there from main
> account.....
>
> second domain config:
>
> server {
>   listen 80;
>   server_name mydomain.com;
>   return 301 $scheme://www.mydomain.com$request_uri;
> }
> server {
>   listen 80;
>   server_name blog.mydomain.com;
>   root /home/nginx/domains/firstdomain/public/blog;
>   index index.php;
>   access_log /var/log/nginx/blog.gogadget.gr_access.log;
>   error_log /var/log/nginx/blog.gogadget.gr_error.log;
>   location / {
>     try_files $uri $uri/ /index.html /index.php?$args;
>   }
> }
> server {
>   listen 80;
>   server_name www.mydomain.com dev.mydomain.com;
>   root /home/nginx/domains/firstdomain.com/public;
>   index index.php;
>   access_log /var/log/nginx/mydomain.com_access.log;
>   error_log /var/log/nginx/mydomain.com_error.log;
> location /go {
>   return 301 http://www.mydomain.com/;
> }
>   location / {
>     try_files $uri $uri/ /index.html /index.php?$args;
>   }
>   location /blog/ {
>     deny all;
>   }
> error_page 500 502 504 /500.html;
>   location ~*
> ^.+\.(?:css|cur|js|jpg|jpeg|gif|ico|png|html|xml|zip|rar|mp4|3gp|flv|webm|f4v|ogm)$
> {
>     access_log off;
>     expires 30d;
>     tcp_nodelay off;
>     open_file_cache max=3000 inactive=120s;
>     open_file_cache_valid 45s;
>     open_file_cache_min_uses 2;
>     open_file_cache_errors off;
>   }
>   location /api2/ {
>     rewrite ^/api2/(.*)$ /api/public/index.php?route=$1 last;
>   }
>   location ~* /(uploads|public)/ {
>     access_log off;
>     expires 30d;
>   }
>   location ~ /\.ht {
>     deny all;
>   }
>   include /usr/local/nginx/conf/staticfiles.conf;
>   include /usr/local/nginx/conf/php.conf;
>   include /usr/local/nginx/conf/drop.conf;
>   include /usr/local/nginx/conf/block.conf;
>   #include /usr/local/nginx/conf/errorpage.conf;
> }
>
> Any ideas?
>
> I am using ZendOpcache and Memcached...
>

do you mean mydomain.com forwarding to www.mydomain.com (your
anonymising is rather confusing)? This is the real TTFB, rather than the
nginx redirect. To address that, you need to tune the server resources,
allocating enough to the database and php-fpm.

Assuming a virtual server, the most important thing to do is to avoid
using disks wherever possible, which means allocating plenty of mem to
the database ( also look at maybe using Percona and innodb to improve
performance ), and caching whatever you can... If not using the latest
versions of PHP, look at using APC as well ( start simple! ) and I find
that redis performs better than memcached, but a tmpfs backed file
system often is better than both ( on a single server platform ).

Temporarily using something like new relic may also help you pinpoint
your bottlenecks.

If I've misunderstood, then maybe it's a DNS problem? Try ensuring all
domain names are set in /etc/hosts ( and maybe set them to something in
the 127.0.0.0/8 subnet to ensure no extra external traffic.

But it's unlikely to be a nginx problem.

hth

Steve
--
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

vedranf
Hi

Thanks for your reply :)

"do you mean mydomain.com forwarding to www.mydomain.com"

No!

I have two domains let's say domain1.com and domain2.com

Both domain files are in public folder of domain1 and the domain2 is using a
folder there named "gadgets"

Now i was set one account for each domain on nginx but on domain2 i use a
redirect to "gadgets" folder ....

Yes it seems that there is a problem with an http request or dns overhead
but no idea how to solve :(

At /etc/hosts i have only the first domain.Do you think this is the problem
and what exactly i must add there for the second domain?

127.0.0.1   localhost localhost.localdomain
37.187.xxx.xxx server.domain1.com server

Both domains are using the same ip!

Thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255913,255915#msg-255915

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

vedranf
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

Steve Holdoway
On Tue, 2014-12-30 at 20:20 -0500, ASTRAPI wrote:
> http://i59.tinypic.com/20jlrpv.jpg
>
Looks like it's server side processing problems then.

--
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

oscaretu .
In reply to this post by vedranf
Hello

Can you use tools like strace or sysdig to see where the time is being lost?

Greetings,

Oscar

On Wed, Dec 31, 2014 at 12:34 AM, ASTRAPI <[hidden email]> wrote:
Hi

On my Nginx server i use a domain "domain.com" and i have all files here:

/home/nginxs/domains/mydomain.com/public


There i have a folder named "gadgets" and i have some files there and i use
a redirect to another domain for this folder.

So if a user types seconddomain.com it goes to the folder gadgets in the
first domains folder and get al results.....

The problem is that is very slow (first domain is loading super fast !) and
then checking i found this :

So Time to first byte is very slow 6 seconds :(

No idea how can fix this :(

And i can't move that folder to the new created account that i redirect as
the files inside gadgets are interacting with other files there from main
account.....

second domain config:

server {
  listen 80;
  server_name mydomain.com;
  return 301 $scheme://www.mydomain.com$request_uri;
}
server {
  listen 80;
  server_name blog.mydomain.com;
  root /home/nginx/domains/firstdomain/public/blog;
  index index.php;
  access_log /var/log/nginx/blog.gogadget.gr_access.log;
  error_log /var/log/nginx/blog.gogadget.gr_error.log;
  location / {
    try_files $uri $uri/ /index.html /index.php?$args;
  }
}
server {
  listen 80;
  server_name www.mydomain.com dev.mydomain.com;
  root /home/nginx/domains/firstdomain.com/public;
  index index.php;
  access_log /var/log/nginx/mydomain.com_access.log;
  error_log /var/log/nginx/mydomain.com_error.log;
location /go {
  return 301 http://www.mydomain.com/;
}
  location / {
    try_files $uri $uri/ /index.html /index.php?$args;
  }
  location /blog/ {
    deny all;
  }
error_page 500 502 504 /500.html;
  location ~*
^.+\.(?:css|cur|js|jpg|jpeg|gif|ico|png|html|xml|zip|rar|mp4|3gp|flv|webm|f4v|ogm)$
{
    access_log off;
    expires 30d;
    tcp_nodelay off;
    open_file_cache max=3000 inactive=120s;
    open_file_cache_valid 45s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
  }
  location /api2/ {
    rewrite ^/api2/(.*)$ /api/public/index.php?route=$1 last;
  }
  location ~* /(uploads|public)/ {
    access_log off;
    expires 30d;
  }
  location ~ /\.ht {
    deny all;
  }
  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  include /usr/local/nginx/conf/block.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
}

Any ideas?

I am using ZendOpcache and Memcached...

Thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255913,255913#msg-255913

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx



--
Oscar Fernandez Sierra
[hidden email]

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Redirect to domain TTFB very slow

vedranf
You can see it i think here:

http://i59.tinypic.com/20jlrpv.jpg

Or not?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255913,255921#msg-255921

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx