How to make Drupal 7 fast with Memcached + Varnish + Nginx + PHP-FPM on Ubuntu
Just in 40 minutes ago, i write article about using Memcached + Nginx + Php-fpm on Drupal 7. I wrote that articles in same time experimenting my development server ( yoodey.com ). I'm satisfhy with NGINX + Memcached and it change until i have thinking about combine it with Varnish. Yes, it sound crazy for me, but i think it is good way to deliver Drupal 7 in HIGH WAY!
So, the step is :
1. Memcached + Varnish + NGINX installation
you can go to my previous articles : Memcached + Nginx + Php-fpm on Drupal 7.
2. Change /etc/nginx/sites-available to works with Varnish
We should change NGINX 80 port into 8082.
<?php
server {
listen 8082; ## listen for Varnish
server_name localhost;
root /var/www/;
access_log /var/log/nginx/drupal.access.log;
if (!-
e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
# if the file is not imagecached, create one
location ~ /files/imagecache/ {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
# just send a empty response if the favicon.ico is m.i.a
location = /favicon.ico {
try_files /favicon.ico =204;
}
# hide protected files
location ~*.(.htaccess|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$ {
deny all;
}
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
?>3. For Varnish installation, you can go to : How to Varnish + Drupal 7.
4. Restart Nginx & Varnish service by :sudo service nginx restartsudo service varnish restart
HTTP/1.1 200 OK
Server: nginx/0.7.67
Content-Type: text/html; charset=utf-8
X-Powered-By: PHP/5.3.3-1ubuntu9.3
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sat, 09 Apr 2011 19:28:16 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "1302377296"
X-Generator: Drupal 7 (http://drupal.org)
Content-Length: 9752
Date: Sat, 09 Apr 2011 19:28:16 GMT
X-Varnish: 570209332
Age: 0
Via: 1.1 varnish
Connection: keep-aliveYour Drupal7 now should fast than 127.0.0.1, ever!
Comments
Denny (not verified)
Sat, 05/28/2011 - 04:24
Permalink
Slow
I was browsing through your website just to see how was the response time. But I didnt see any performance improvement and it was too slow. Are you sure your configurations are correct? If you run even nginx alone with memcache, the response time is very fast. I guess the problem is you are allowing to run php for anonymous users. Thanks
admin
Tue, 05/31/2011 - 02:29
Permalink
Dear Denny
I have upgrade my server in several day before and this may be affected yours. I tried test this page using browsermob.com ( http://browsermob.com/free-website-performance-test/5f7dcba289e3441999b3... ) and it gave me 1.96 seconds which i think this is fast enough.
Please test this page again and give me feedback if still give slow performance. Cheers
Tim Millwood (not verified)
Mon, 05/30/2011 - 15:12
Permalink
Varnish maybe serving you
Varnish maybe serving you page, but according to those headers you are showing, Varnish is not serving a cached page.
admin
Tue, 05/31/2011 - 02:30
Permalink
Dear Tim
Indeed, i don't use varnish right now because i give a try to NGINX + memcached. Also i have another python running in this server.
Also, Varnish is not serving a cached page is true and i will remember that :)
Metin (not verified)
Tue, 06/14/2011 - 22:17
Permalink
permission
how did you set the permissions?
admin
Thu, 06/16/2011 - 04:12
Permalink
for Nginx
For nginx, you can set permission at nginx.conf
peter (not verified)
Tue, 02/14/2012 - 16:03
Permalink
Hi, did you finish the
Hi, did you finish the deployment of varnish? I think the speed is still too low, I am now preparing a newsite either with joomla or drupal (which I don't have any experience before), thanks!
admin
Fri, 02/17/2012 - 14:02
Permalink
Sure
Sure, I finish and this site (Drupal) use Varnish and Apache2 ( because I need mod-wsgi to handle Django applications )
James (not verified)
Sat, 03/10/2012 - 12:31
Permalink
Here's what I get for http:/
Here's what I get for http://yoodey.com/:
The Last-Modified header's value isn't a valid date.
This response is negotiated, but doesn't have an appropriate Vary header.
The response body is different when content negotiation happens.
During validation, the ETag didn't change, even though the response body did.
I'm using nginx - php-fpm with eaccelerator. Considering Varnish but you don't seem to be using it on this site so maybe its not that great.
admin
Mon, 03/12/2012 - 10:30
Permalink
Thanks
Hi James, Thanks for correction.
Indeed, I'm not using Varnish because I recently move my site into new server, which I don't have much time to use same configuration with the past.
MarkyMark (not verified)
Wed, 05/16/2012 - 07:48
Permalink
yo
ah its not wordpress, its drupal right?
HardyLatte (not verified)
Thu, 05/17/2012 - 04:31
Permalink
wow
what a great post, just signed up to your RSS feed and hope to read more of your posts in the future. keep it up!
Add new comment