Jump to content

Varnish, PHP, and CDN Question


Recommended Posts

Posted

I have been working hard on improving my site's performance, and I now have a question for you optimization Gurus.

Will Varnish help improve the performance of my site/server?

I know, loaded question, right? Let me tell you about my configuration and observed performance:

Performance: (http://www.webpagetest.org/, Dullas, IE9, FIOS)

  • Time To First Byte - Consistently 400MS to 550MS
  • Page Load Time - Consistently 1.2s to 2.0s range

Note: This is while running 2 AdSense banners per page, which admittedly hurts Load times)

IPB Config:
  • CDN subdomain for "Images, CSS and JS"
  • CDN subdomain for Uploads and Gallery (I had seperated the Uploads and Gallery into two CDNs, but the performance improvement did not seem to offset the increased DNS lookup time)
  • "Disable GZIP encoding" = Yes
  • "Enable content caching" = Yes
  • "Load javascript files from Google" = No (the files seem to be served faster through my CDN)
  • "Allow custom profile field info be used in topic view" = No
  • Running IP.SEO Sitemap Generation in Cron
  • Google Analytics code loaded at bottom of page, right before /body (Google documented page load improvement)
  • "Disable prefetching" = No

Server:
  • cPanel VPS with 2.68GHz CPU and 1824MB of RAM
  • Apache 2.2.20 (mod_fcgid/2.3.6, KeepAlive=150, mod_deflate installed, suEXEC=On
  • PHP v5.3.8
  • Zend Engine v2.3.0 (Obfuscation level=3)
  • eAccelerator v0.9.6.1 (Memory Size = 64MB)
  • ionCube PHP Loader v4.0.9
  • Zend Guard Loader v3.3
  • MySQL v5.1.56 ("Sessions" Table Type set to MEMORY)


.htaccess contents:


<IfModule mod_rewrite.c>


Options -MultiViews


RewriteEngine On


RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f


RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . /index.php [L]


</IfModule>



<IfModule mod_deflate.c>


<FilesMatch ".(js|css|html|htm|php|xml)$">


SetOutputFilter DEFLATE


</FilesMatch>


</IfModule>



<IfModule mod_expires.c>


ExpiresActive On


ExpiresDefault "access plus 2 seconds"


ExpiresByType text/html "access plus 2 seconds"


ExpiresByType image/gif "access plus 120 minutes"


ExpiresByType image/jpeg "access plus 120 minutes"


ExpiresByType image/png "access plus 120 minutes"


ExpiresByType text/css "access plus 60 minutes"


ExpiresByType text/javascript "access plus 60 minutes"


ExpiresByType application/x-javascript "access plus 60 minutes"


ExpiresByType text/xml "access plus 2 seconds"


ExpiresByType image/x-icon "access plus 1 days"


ExpiresByType image/ico "access plus 1 days"


</IfModule>



I don't want to jump the gun, but if the answer is that Varnish will improve performance, then will it improve PHP processing times, or just speed up the serving of images and scripts? How is any of this affected by the fact that I am using a CDN?
Posted

1-2s load time is pretty darn good I'm not sure why you even think you need to improve things. Also providing a link to your forums so we can see how it currently performs might help get more responses.

  • 2 weeks later...
Posted

Performance: (

http://www.webpagetest.org/

, Dullas, IE9, FIOS)


If you want a valid comparison, most tests are done using IE8, and DSL instead of FIOS.


Time To First Byte - Consistently 400MS to 550MS


Pretty good times. I really don't see Varnish offering much improvement. 50-100ms at most.


"Disable GZIP encoding" = Yes


I assume mod_deflate or compression on the server?


"Load javascript files from Google" = No (the files seem to be served faster through my CDN)


Depends on your CDN and the location. You might find Google faster in Asia and Oceania (Australia/NZ). Also, a benefit to using Google is users might have the content already cached by their browser from visiting another IP.Board that pulls content from Google. Finally, older browsers (IE6-7) benefit from domain sharding... More resources downloaded in parallel.


I don't want to jump the gun, but if the answer is that Varnish will improve performance, then will it improve PHP processing times, or just speed up the serving of images and scripts? How is any of this affected by the fact that I am using a CDN?


Varnish is a cache. It's major benefit is that it improves scaling -- you can serve a lot more traffic with less hardware. However, when serving a page from cache MySQL queries are reduced, as is PHP processing. IP.Board also offers caching, but there is a little page load improvement with Varnish. You'd likely notice more improvement with an alternate web server like Litespeed or Ngnix. A CDN will improve latency, Varnish will not. They work well together.
Posted

1. I assume mod_deflate or compression on the server?





2. Depends on your CDN and the location. You might find Google faster in Asia and Oceania (Australia/NZ). Also, a benefit to using Google is users might have the content already cached by their browser from visiting another IP.Board that pulls content from Google. Finally, older browsers (IE6-7) benefit from domain sharding... More resources downloaded in parallel.





3. Varnish is a cache. It's major benefit is that it improves scaling -- you can serve a lot more traffic with less hardware. However, when serving a page from cache MySQL queries are reduced, as is PHP processing. IP.Board also offers caching, but there is a little page load improvement with Varnish. You'd likely notice more improvement with an alternate web server like Litespeed or Ngnix. A CDN will improve latency, Varnish will not. They work well together.



1. Yes, if you notice, I have the mod_deflate call in my .htaccess. Is there a better way?
2. I am using CloudFront.
3. I was seriously thinking of using Litespeed becasue it will drop in place of Apache, but decided not to because it is licensed by CPU core. With 8 cores in my box, the LSWS Licensing cost is nearly 1/2 of my hosting costs. I like everything I have read about Ngnix, but I am very hesitant to install it becasue it does not support .htaccess(which breaks mod_rewrite and mod_deflate).

Since I wrote the first post I have done a few more things.
1. Moved to a dedicated server with dual Xeon 3470 procs
2. Only use eAccelerator for PHP caching (removed from the global_conf file)
3. Using Memcached for IPB caching (added to global_conf file)
4. Removed ZendGuard Loader extension from php.ini
5. Changed the IPB post cache duration to 365 days. (it auto purges cached items that have not been accessed in the past 7 days)
6. Done some tweaking to the MySQL my.conf file to increase the internal caches.
7. Enabled php-fpm through fcgid

My TTFB has dropped to the 200 to 250 range, consistently. I would like it even lower to help make sure that I am getting the page load time below Google's expected page load time of 1.5 seconds.
Posted

When your users change their avatars does it work?



If you notice in my .htaccess file, I havee mod_expire set to 120 minutes. The way the board currently names Avatars is av-XXXXX.jpg, where the XXXXX is their member number. This causes a problem when changing Avatar, and the CDN (or Varnish) does not recache the file until its expiry time (which is up to 120 minutes in my case). Then you have to wait for up to 120 minutes for the persons local cache to expire (or for them to press Ctrl-F5), as the CDN passed a 120 minute expiration time to the browser. I have requested that IP change the avatar naming scheme so it uses a random name/number, or an iterative number. That would make the avatar show immediately.
Posted

3. I was seriously thinking of using Litespeed becasue it will drop in place of Apache, but decided not to because it is licensed by CPU core. With 8 cores in my box, the LSWS Licensing cost is nearly 1/2 of my hosting costs. I like everything I have read about Ngnix, but I am very hesitant to install it becasue it does not support .htaccess(which breaks mod_rewrite and mod_deflate).


You don't need an 8-CPU license just because your server has 8-CPUs. A single CPU license would probably handle your load just fine. A 2-CPU license adds support for Litespeed cache (their faster version of Varnish). Litespeed just runs on one or two cores, leaving the remainder for MySQL, etc.


page load time below Google's expected page load time of 1.5 seconds.



IPB 2.3, or vB3 maybe. IP.Board V3.x (or vB4)? Not a realistic goal. Especially with Adsense. (IE7/8 - DSL)

Do you monitor your site performance in Google Webmaster Tools, or Google Analytics (beta version)? If not, you should. Webmaster Tools performance data comes from actual visitors to your domain who have the Google Toolbar installed.

With 8-CPUs you might investigate Percona. It's a drop in replacement for MySQL that scales better, especially when using more than 4 CPUs, and offers some general speed improvements. Not to mention the excellent XtraBackup that takes the pain out of nightly backups. If you have enough RAM to hold most your tables, InnoDB (Percona XtraDB) will also offer better performance, and much better data integrity.
Posted

Yeah, I monitor those tools. I am still showing at about 2.5 seconds in their too, and 2.8 seconds in GA.

I haven't heard of Percona. I will look into it.

I have some other questions about Nginx. Do you know of any nginx configuration code for fcgid/php-fpm and the items I have in my .htaccess above? I cannot find a thread on here that states a definitive configuration for it.

Posted


If you notice in my .htaccess file, I havee mod_expire set to 120 minutes. The way the board currently names Avatars is av-XXXXX.jpg, where the XXXXX is their member number. This causes a problem when changing Avatar, and the CDN (or Varnish) does not recache the file until its expiry time (which is up to 120 minutes in my case). Then you have to wait for up to 120 minutes for the persons local cache to expire (or for them to press Ctrl-F5), as the CDN passed a 120 minute expiration time to the browser. I have requested that IP change the avatar naming scheme so it uses a random name/number, or an iterative number. That would make the avatar show immediately.




I have this same problem... Wish IPB would make the change.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...