Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Time to first byte...
PostPosted: Mon Jan 16, 2012 9:22 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
So with the help of some folks here and a little personal initiative, I made the switch to nginx/php5-fpm from apache2/mpm-prefork. Everything is running smoothly, except the time to first byte is in the 4.x range - an improvement, but still leaves something to be desired. This might be something I'll wind up needing to pass along to the client (who is the one with WP-admin and control over the site), but as of right now I haven't the foggiest as to the culprit(s). Suggestions?

Site is http://bladereviews.com


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2012 9:58 pm 
Offline
Senior Member

Joined: Tue May 03, 2011 11:55 am
Posts: 105
You know, I have been having the same problem myself but with a completely different setup and software. Time to first byte is around 5 seconds with Litespeed and vBulletin.


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2012 10:15 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
I assume this is a follow-up to this thread?

Interestingly, time to first byte is 4 seconds only on the front page, and subsequent pages all load in around 1 second. When I return to the front page, it's 4 seconds again. This is strange because all pages seem to be using Total Cache. Is there anything special on the front page that might make it slow or un-cacheable?


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2012 10:26 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
The headers seem to indicate the main page isn't cacheable:

Code:
< HTTP/1.1 200 OK
< Server: nginx/1.0.11
< Date: Tue, 17 Jan 2012 02:22:32 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Pingback: http://bladereviews.com/xmlrpc.php
< Link: <http://wp.me/1eZI2>; rel=shortlink
< Last-Modified: Tue, 17 Jan 2012 02:22:32 GMT
< Vary: Cookie
< X-Powered-By: W3 Total Cache/0.9.2.4


(a little while later)

Code:
< HTTP/1.1 200 OK
< Server: nginx/1.0.11
< Date: Tue, 17 Jan 2012 02:24:06 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Pingback: http://bladereviews.com/xmlrpc.php
< Link: <http://wp.me/1eZI2>; rel=shortlink
< Last-Modified: Tue, 17 Jan 2012 02:24:06 GMT
< Vary: Cookie
< X-Powered-By: W3 Total Cache/0.9.2.4


The Last-Modified time there should be before now. Only difference between the two outputs is the timestamp from W3 Total Cache:

Code:
$ diff /tmp/bladereviews.1 /tmp/bladereviews.2 
629c629
< Served from: *.bladereviews.com @ 2012-01-16 19:22:32 -->
---
> Served from: *.bladereviews.com @ 2012-01-16 19:24:06 -->


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2012 10:48 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
hybinet wrote:
I assume this is a follow-up to this thread?

Interestingly, time to first byte is 4 seconds only on the front page, and subsequent pages all load in around 1 second. When I return to the front page, it's 4 seconds again. This is strange because all pages seem to be using Total Cache. Is there anything special on the front page that might make it slow or un-cacheable?

In a manner of speaking, yes; though, like I said, since then I've gone to nginx+php5-fpm. I credit some folks here for the help because I searched around before posting ;)

And yes, I noticed that, as well. I don't have access to the WP Dashboard, so I'm not certain what might set the index page apart.

hoopycat wrote:
The headers seem to indicate the main page isn't cacheable:

Code:
[...]


(a little while later)

Code:
[...]


The Last-Modified time there should be before now. Only difference between the two outputs is the timestamp from W3 Total Cache:

Code:
$ diff /tmp/bladereviews.1 /tmp/bladereviews.2 
629c629
< Served from: *.bladereviews.com @ 2012-01-16 19:22:32 -->
---
> Served from: *.bladereviews.com @ 2012-01-16 19:24:06 -->

Alright, I'll see about getting him to let me have a look at his cache config and report back. Thanks fellas.


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 1:09 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
W3 Total Cache has a mind-boggling array of different caching modes. I wouldn't be surprised if it served a cached page (or constructed it from a number of cached HTML snippets) and then added headers and a comment with individualized timestamps. This, of course, requires firing up the WordPress engine and loading the heavyweight caching plugin every time. Much less efficient than simply serving a static file.


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 12:03 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
Touched base with the client and told him to take a look at his config, he's seeing:

Quote:
It appears Page Cache URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.


and

Quote:
It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.


I used the W3TC rewrite rules for nginx found here during initial config:

http://codex.wordpress.org/Nginx#W3_Total_Cache_Rules

Maybe needs some tweaking?


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 2:44 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
rawsted wrote:
http://codex.wordpress.org/Nginx#W3_Total_Cache_Rules

Those rules look incomplete. There's not a single "rewrite" in there. It's not rewriting any URLs, only adding browser cache headers to static files.

Unfortunately, I can't seem to find anything better.


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 2:56 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
hybinet wrote:
Those rules look incomplete. There's not a single "rewrite" in there. It's not rewriting any URLs, only adding browser cache headers to static files.

Unfortunately, I can't seem to find anything better.

So there isn't...well, surely someone else is running nginx/WP/W3TC here...what are they using?

Also, how the hell is the site working with no explicit index.php/args rewrite?


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 3:27 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
rawsted wrote:
Also, how the hell is the site working with no explicit index.php/args rewrite?

Isn't that what the General WordPress Rules are for?

I just found this. It's a bit old, but it might help. Even if that's not exactly what you need, a proper rewrite rule for a caching plugin should look something like that.


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 3:32 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
hybinet wrote:
Isn't that what the General WordPress Rules are for?

Yes, I was just here myself looking back at these and realized I was missing the:

fastcgi_split_path_info ^(.+\.php)(/.+)$;

Directive. However, it doesn't resolve the "...rewriting not working" messages in W3TC

hybinet wrote:
I just found this. It's a bit old, but it might help. Even if that's not exactly what you need, a proper rewrite rule for a caching plugin should look something like that.

Just tried this, doesn't seem to be doing the trick, either.

Edit:
Do'h...W3TC has rewrite rules for nginx listed *in* the installer...I'm going to make sure it's the latest version, update if necessary, implement those and report back.


Last edited by rawsted on Tue Jan 17, 2012 3:56 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 3:55 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
Alright! Implementing those cleared the page cache/minify rewrite error notices...but the index page still loads relatively slowly. Current server response headers:

Code:
Cache-Control:no-cache, must-revalidate, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Tue, 17 Jan 2012 19:52:59 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Tue, 17 Jan 2012 19:52:55 GMT
Link:<http://wp.me/1eZI2>; rel=shortlink
Pragma:no-cache
Server:nginx/1.0.11
Transfer-Encoding:chunked
X-Pingback:http://bladereviews.com/xmlrpc.php
X-Powered-By:W3 Total Cache/0.9.2.4


Code:
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Tue, 17 Jan 2012 19:52:55 GMT

Culprits?


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 4:03 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
Interestingly, another page which loads rapidly shares the same response headers:

Code:
Cache-Control:no-cache, must-revalidate, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Tue, 17 Jan 2012 20:01:40 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Tue, 17 Jan 2012 20:01:39 GMT
Link:<http://wp.me/P1eZI2-s1>; rel=shortlink
Pragma:no-cache
Server:nginx/1.0.11
Transfer-Encoding:chunked
X-Pingback:http://bladereviews.com/xmlrpc.php
X-Powered-By:W3 Total Cache/0.9.2.4


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 4:34 pm 
Offline
Junior Member

Joined: Sat Jan 07, 2012 4:15 pm
Posts: 23
Strangely enough, the time to first byte metric is now down into an acceptable (you might even say fast) range. Perhaps the cache just needed some time to catch up after the configuration correction? Let's look at the headers again...

Code:
Connection:keep-alive
Content-Encoding:gzip
Date:Tue, 17 Jan 2012 20:30:27 GMT
Last-Modified:Tue, 17 Jan 2012 19:46:24 GMT
Server:nginx/1.0.11
Vary:Accept-Encoding, Cookie
X-Powered-By:W3 Total Cache/0.9.2.4


Looks better. Thanks fellas!

As an aside, what should I set the keepalive timeout in nginx for? Atm it's 30


Top
   
 Post subject:
PostPosted: Tue Jan 17, 2012 5:01 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
rawsted wrote:
As an aside, what should I set the keepalive timeout in nginx for? Atm it's 30

30 is much longer than necessary, because most pages finish loading in just a few seconds. But usually it doesn't matter because idle connections consume very little resources in nginx. That's one of the most significant differences between Apache+PHP and nginx.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group