Showing posts with label proxy. Show all posts
Showing posts with label proxy. Show all posts

Sunday, January 18, 2009

MemcachedPageCacheManager- A faster PageCache

With Plone's CacheSetup tool, it's pretty easy to get better performance out of Plone. In fact, with really aggressive caching, using Varnish as the proxy I've gotten up to 1000 reqs/sec.

Varnish and Squid are so great, why something else?

Fear of stale content. There are some scenarios where there is no reliable way of purging the proxy cache when a cached item has changed. In these cases, caching in memory via the Page Cache Manager is the solution. The alternative would risk serving stale content when an item is changed.

Cache Setup handles all of this on your behalf, except I had a yearning for faster performance.
So I got a hold of MemcachedPageCacheManager (had to do an svn checkout from the collective). I also need to install memcached (on Ubuntu that's 'aptitude install memcached).

The performance on a modest server (1 GB Ram, 1.6 ghz) looked like this:

Without CacheSetup: 0.2 requests/per/second
With CacheSetup installed and enabled (no tweaking): 3 to 4 requests/per/second
With CacheSetup installed and MemcachedPageCacheManager: 40 requests/per/second

So doing a drop in replacement of PageCacheManger with MemcachedPageCacheManager gave me a 10 fold performance increase.

Important Notes

MemcachedPageCacheManager does not provide a way to edit the "Page Cache threshold entries" and the "Cache cleanup interval (seconds)". As a result this breaks the Cache Settings > Memory Tab (page_cache_config.cpt). I created my own version of the "Memory Tab" via, mostly because, cosmetically it looked better.

This

looked better than This:

Wednesday, September 17, 2008

NGINX entity too large, no more

Sometimes a simple sentence can make a world of difference. It did that for my nginx configuration this morning. Since setting nginx in front of Plone, I've had an "413 entity too large" error for files bigger than 1 MB.

My configuration uses a special conf/proxy.conf file which looks like this::

# proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 30m;
client_body_buffer_size 2m;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 2m;
proxy_buffers 4 1m;
proxy_busy_buffers_size 2m;
proxy_temp_file_write_size 2m;

The wrong way

Previously my 'server' section in my nginx.conf used to look like this:

server {
listen 1.2.3.4;
server_name example.com www.example.com;
location / {
rewrite ^/(.*)$ /VirtualHostBase/http/www.example.com:80/example/plone/VirtualHostRoot/$1;
}
location /VirtualHostBase/ {
proxy_pass http://sharedhosting;
include conf/proxy.conf; #this is apparently a bad place to put this
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}


The right way

So I read the following comment at the slicehost forums:

"Try moving the directive from inside the location block to just inside the server block."


So now I've moved it to "just inside the server block" so my 'server' section in my nginx.conf now looks like this:

server {
listen 1.2.3.4;
server_name example.com www.example.com;
include conf/proxy.conf; #now it works, phew!
location / {
rewrite ^/(.*)$ /VirtualHostBase/http/www.example.com:80/example/plone/VirtualHostRoot/$1;
}
location /VirtualHostBase/ {
proxy_pass http://sharedhosting;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos