The default Apache settings are optimized for a website serving static files only. Check your /etc/apache/mods-enabled folder to see what can be removed. This should be fairly obvious, but Apache ships with a number of modules which can affect performance but which most of us never need. Let’s examine ways in which we can make our dynamic Apache settings much faster. If nothing else, it provides a safety net and teaches you how to squeeze every ounce of performance out of big and small server instances. It’s so easy (and cheap!) to spin up a small server cluster for some serious load testing, and then destroy it again when done. One of my favourite aspects of the cloud is the ease with which we can create new VMs to test our wacky architecture theories. Tags: apache, memcached, MySQL, nginx, PHP, varnish I’ll experiment with this setup in the coming months and post my results. Since the majority of my site traffic comes from search engine results where a user has not yet been registered to the site or needs refreshed content, Varnish can step in and serve a fully cached version of my pages from memory far faster than FastCGI can render the WordPress code. My next step will be to put a varnish server in front of nginx. All of the requests parameters are passed through to PHP, and once the configuration is started up I didn’t miss Apache one little bit. The fastcgi_param setting controls which script is executed, based upon the root path of the site being accessed. # this sends all-non-existing file or directory requests to index.phpįastcgi_param SCRIPT_FILENAME /www//html$fastcgi_script_name # this serves static files that exists without Server_name access_log /var/log/nginx/sitename-access.log Įrror_log /var/log/nginx/sitename-error.log Since the majority of my static content (css, javascript, images) have already been moved to a content delivery network, nginx has very little actual work to do. Once PHP FPM was installed, I created a site entry that would pass PHP requests forward to the FastCGI server, while serving other files directly. (Maybe we can get into this another time.) Once installed, you can tweak your php.ini settings to suit, depending on your system’s configuration. The newest Ubuntu distributions have a package php5-fpm that installs PHP5 FastCGI and an init.d script for it. I went into a lot more detail about this last April when I wrote about how to use memcached as a session handler in PHP. Using memcached for sessions gives me slightly better performance on my Rackspace VM because in-memory reading&writing is hugely faster than reading&writing to a virtualized disk. Here are the configuration steps I took to realize this stack: Additionally, I used memcached to store sessions rather than writing to disk. Since nginx doesn’t have a PHP module I had to use PHP’s FastCGI (PHP FPM) server with nginx as a reverse proxy. Not long ago, I described my web stack and explained why I moved away from the “safe” Apache server solution in favour of nginx. We want our server to send page data as immediately as possible so the browser can begin rendering it and downloading supporting files. The speed of execution at the server level is capable of making or breaking the user’s experience by controlling the amount of ‘lag time’ between the web page request and visible activity in the web browser. I’ve been very interested in web server performance because it is the first leg of the web page’s journey to the end user. But do take the time to download YSlow today and use its suggestions to start making radical improvements. If your website isn’t the fastest it can be, you can take some comfort in the fact that the majority of the “top” web sites also suffer from page load times pushing up into the 10 second range (have you BEEN to Amazon lately?). This is particularly bad if you’re trying to run a web site that relies on visitors to generate some kind of income – content is king but speed keeps the king’s coffers flowing. Studies have shown that viewers waiting more than 2 or 3 seconds for content to load online are likely to leave without allowing the page to fully load. All web site owners should feel a burning need to speed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |