Compiling PHP with Oracle support on CentOS 5.2
Getting PHP and oracle to play nice is a massive pain, so this post is more a log for myself next time I have to do it more than anything else!
The procedure requires you to compile PHP from source, so if thats not your thing or your easily scared don’t bother continuing!
Firstly an enormous yum install command to get everything we need in one go:
# yum install openssh-server httpd httpd-devel apxs libx openssl-devel curl-devel libpng-devel\ oci8-devel libxml libxml2 libxml2-devel libjpeg libXpm libXpm-devel libpng libxslt libxslt-devel\ freetype freetype-devel
Go and grab the instant client from the oracle website and install it with RPM:
# rpm -i oracle-instantclient11.1-basic-11.1.0.7.0-1.i386.rpm # rpm -i oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm
And then get the PHP source (substitute for whatever the latest version is at your compile time obviously):
# wget http://uk.php.net/get/php-5.2.8.tar.gz/from/this/mirror # tar -xzf php-5.2.8.tar.gz # cd php-5.2.8
And finally configure it all together:
# ./configure --with-apxs2=/usr/sbin/apxs --with-zlib --without-gdbm --enable-force-cgi-redirect\ --enable-ftp --enable-xml --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin\ --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib\ --libexecdir=/usr/libexec --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info\ --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pear --enable-pdo\ --with-oci8=instantclient,/usr/lib/oracle/11.1/client/lib --with-pdo-oci=instantclient,/usr,11.1\ --with-xsl --with-curl --with-openssl --enable-soap --enable-sockets --enable-sigchild --enable-xdebug\ --with-jpeg-dir --with-xpm-dir --with-png-dir --with-freetype-dir --with-ttf --enable-gd-native-ttf --with-gd
And with a bit of luck you should be up and running. Obviously now you have to do battle with Oracle itself which is a minefield of confusion!
How to quickly setup a load balanced, high availability, Apache cluster
I wanted to find a simple to maintain and expand soultion for load balancing a web cluster with high availability. I have found my solution in HAProxy.
Scenario
This demo scenario is in the following enviroment:
- Network Configuration
- Network: 192.168.11.0
- Subnet Mask: 255.255.255.0
- Gateway: 192.168.11.254 (Although this is irrelavant)
- 1 x Shared IP for the Load Balancers
- 192.168.11.40
- 2 x Load Balancers
- BHLabs1 – 192.168.11.30
- BHLabs6 – 192.168.11.39
- 4 x Web Servers
- BHLabs2 – 192.168.11.35
- BHLabs3 – 192.168.11.36
- BHLabs4 – 192.168.11.37
- BHLabs5 – 192.168.11.38
At the start of this setup all machines are running Ubuntu 8.04 Server from a standard install with openssh-server installed and the root password set. All setup commands are run as root or with sudo. (more…)
The Gospels of my Performance Web Hosting Bible
There are certain things I keep close to hand when I’m presented with a new site by our development team. I use these sites and books as a basis for most criticisms, decisions and tweaks I make when deploying a new site. This detail in these guides is generally focused on LAMP sites, although the logic applies to any hosting arrangement.
Yahoo! Performance Team Research
January last year Yahoo! published possibly the most influential piece of research on the importance of speed and delivery performance when serving websites. They identified that 40-60% of Yahoo!’s users hit the site with an empty cache, and that 20% of all page views were done with an empty cache. Combine that with the knowledge that page loads times have an adverse effect on UX after 3-5 seconds of waiting and you see the importance. Keeping this in mind forms the base goal for performance hosting.
Yahoo! Performance Team Best Practices Guide & YSlow
On that note, my first gospel is the Yahoo! performance team’s Best Practices guide. I follow this guide almost religiously, and won’t rest until I’m happy the majority of points are covered. So far I’ve had nothing but extreme success following these tips. Yahoo! have released a fantastic tool based on these rules called YSlow, and extension for Firebug. This extension monitors the page load, and analyzes all the components on your page. It then scores your page and provides you with a list of suggestions to enhance performance.
Website Optimization – Andrew King
The second gospel is Website Optimization by Andrew King. This is a must read book for anybody who’s serious about performance on their web site. Not just performance hosting, but this book goes in to conversions and analytics as well as considerations when actually building the pages such as JS minification, image size optimisation in Photoshop (and not just Save for Web!), pre-loading and post-loading.
Planning Considerations
Third gospel would be Kent Langley from Joyent’s guide on designing sites that scale well. This guide I don’t consider as a point of education for me, rather proof that it’s not just me! His description of the considerations he makes daily echos my exact thoughts on scalability during the design and build process. Scalability and performance go hand in hand really, and
Simple Apache tweaks every site should have
I’m going to have to include my own guide in here from a few posts ago. It contains some very simple copy and paste entrys for your Apache config files that I believe nearly every site should have. This includes things like expire headers and mod_deflate.
Running a Big Web Site
Apache The Definitive Guide, by Ben and Peter Laurie, Chapter 12: Running a Big Web Site. This is a chapter full of what should be common sense to any web host. Of particular note though is the section on scalability and the section on load balancing and how to use mod_backhand if you can’t afford or justify a dedicated hardward solution.
Tweaking your worker limits
Apache Performance Tuning from DeveloperSide.net has a good step by step on calculating what all your prefork.c variables etc should be set to for pest performance and utlisation. Configuring this correctly is essential on a high traffic site and it’s a very fine ballance between protecting the stability of the server or cutting off your users at a way lower number than you should be. One wrong step in the wrong direction can leave you in either a massively over-cautious enviroment, where your servers load is sat somewhere around 0.3 but you can’t get a page displayed, or you can fly into a load of 150, with no chance of being able to SSH to the server let alone serve content!
4 Simple Apache tweaks to speed up delivery of your web site
Add these simple directives into your Apache configuration and you should notice a considerable increase in speed in the delivery of pages. As a working example, I performed these tweaks on http://www.shortlist.com/. Here are the before and after stats:
The changes are:
- Homepage on an empty cache from 956.6k to 658.9k, both 133 requests.
- Homepage on a primed cache from 153.9k and 128 requests, to 25.9k and 8 requests. (more…)
When tweaking performance settings in Apache…
This post is to do with a discovery I made while making performance tweaks on the webservers for http://www.tottenhamhotspur.com. This particular setup has six loadbalanced webservers and eight database back-ends designed to cater for a high amount of shorter bursts of traffic.
There was problem however with the site not responding, even though the servers were under a tiny load, and the load balancer was not under much stress. I could connect to localhost just fine (telnet is a magnificent troubleshooting tool, is it not?). Running `ps ax|grep httpd | wc -l` I counted exactly 256 threads running for Apache. So I went and edited httpd.conf and raised ServerLimit and MaxClients to 1024 (from 256). I then restarted the service with apachectl graceful. Went back and checked during the next days traffic, and it was still not responding. When looking at the error log:
WARNING: MaxClients of 1024 exceeds ServerLimit value of 256 servers, lowering MaxClients to 256. To increase, please see the ServerLimit directive.
This confused me as I had changed both values, and confirmed this with cat on the conf file. it appeared the ServerLimit value was being ignored. I tried an apachectl restart in case graceful was leaving zombies, but that made no difference either. It turns out, that you have to do a full graceful-stop and start on Apache in order for it to pick up the change in ServerLimit. Annoying?!


