Converting caffeine to code, shooting pics, and cruising the roads of life.

Archive for the ‘Apache’ Category

An Apple for Thanksgiving.

Wednesday, November 22nd, 2006

I would like to wish everyone that reads this blog a happy Thanksgiving. Hope you all don’t eat too much. I know I will be tomorrow…maybe even with an Apple. Yep, my new 17″ MacBook Pro finally came on Monday and today is the first day I’ve really put the time into learning how to use OS X. So far, I’m completely amazed, it’s a very nice system. I like how all the applications seem to work together for even simple tasks.

The Kenwood Apple Store was true to their word, they called me the day they came in. I ended up getting to the store around 6:30-7pm and it was packed. These things must be selling like hotcakes because I know they sold 3 of them while we were waiting on the cashier to see if they had any 2gb ram sticks in stock — which they didn’t. So I’m still 1gb of ram short until my reserved stick comes in. They do have a nice deal going right now though. You can get an HP Photosmart C3180 printer for free with your MacBook if you are buying it on a college discount. You have to pay upfront, but you get a rebate for the full price of the printer, similar to how they were running the iPod deals.

So far my experience of moving from Linux to OSX has been pretty grand, as I hinted at above. The built in wireless coupled with my new WRT45G, that I hadn’t tested the wireless on, seem to be working much better than my old setup. It’s so nice having wireless again, no cat5 cable to get tangled up in my mouse. Application-wise, I have already found a replacement for everything I used on Linux. I knew all of these before I even owned a Mac though, since I talk to/code with a few people that own a mac.

Heck, in the three days I’ve had this thing, I’ve already spent $50 in software. I bought textmate since it appears to be the best coding text editor on the planet for the mac and web 2.0 crew. I’m definitely liking it so far, but I’m on the hunt for PHP plugins now. They are a bit saturated with Ruby plugins. ;) I still need to get a legal copy of Photoshop CS2 for this box though. If only it was cheaper…

I’ve also had the joy of being able to run a lot of my favorite Linux applications on this thing. Fink is quite a nice system. I already have X11 running at startup, without that stupid xterm. I’ve modified my shell settings so everything I need to start X apps from Terminal.app is there and ready to go. I suggest all of you go out and install Xdroplets. Combined with this custom X11 setup and Xdroplets, I have a pretty standard application interface for running my old applications, such as XMMS or Konqueror for testing.

To give you some idea of how fast this laptop is, I have two benchmarks for you. While I was writing this post, I started a compile of Apache 2.0.59 to start setting up my development environment for ThreadBound. Here are the command that I ran:

$ ./configure
$ export MAKEOPTS=”-j6″
$ time make

What are the results? Astounding, considering this is a 10-20 minute compile on my old Athlon64 3200+ laptop…

real 1m37.240s
user 0m53.671s
sys 0m37.242s

The other benchmark is from when I installed Windows XP on my friend’s MacBook Pro, which is identical to the one I bought. After installing Counter-Strike: Source, we ran the video stress test. These machines averaged 114 FPS on it. This test set all of the settings on high, so we tried it. We were getting about 60-90 FPS at 1680×1050 during games. This just goes to show you the performance of this machine. Considering that people don’t know that the x1600 graphics cards they ship with are underclocked by around 45% below what ATI ships them as, due to heat. So I’m going to have to overclock them a bit and see how it does.

Here is a nice picture of my MacBook Pro:

Macbook Pro Core 2 Duo OpeningMacbook Pro Core 2 Duo Opening Hosted on Zooomr

More pictures of it can be found here.

ThreadBound.com

Monday, August 7th, 2006

Well, we came up with the new name and the teaser page is up. Have fun. ThreadBound.com I’ll make a logo soon as Alpaca gets back from Canada. Fill out the form if you want updates.

OSX and the APC battle

Saturday, June 3rd, 2006

So over the period of a week, I’ve been helping Alpaca get a MAMP (The setup, not the prepackaged deal) setup going off and on. So starts a huge adventure.

We first started looking at darwin ports, but we soon realised that it did everything we didn’t want it to. Disabled most PHP modules, disabled pear and pecl, and just flat out didn’t work for what we needed. The only thing that did work was the MySQL port…

So we went over to the MAMP camp. We thought we had it. There it was, a prepacked installer with Mysql 5, PHP5, apache, and all the PHP extensions required but two pecl ones. Little did we know… So the first task at hand was to disable eAccelerator. This was easily done in a control panel, but the rest wasn’t. MAMP doesn’t add any of the binaries to your shell’s PATH, so we had to do that so we could use pecl.

From there, we tried to install APC and so the trouble began. We were loaded up with errors about Apache’s APXS and config_vars.mk. I quickly solved the APXS file issues, but the config_vars.mk was a stumper. We could not make it work, even putty an old one there, since MAMP doesn’t have one.

So now, we’re going hardcore. I’m just going to tell him how to compile them from source so we don’t lose anymore time, because this one day job has taken WAY too long to do.

P.S. I’m still working on that new design, just a bit preoccupied at the moment. I also have an APC/Memcached article 75% finished.

High Traffic Web Development

Sunday, April 16th, 2006

Over the past week and a half, I have been in the process of reading up on developing for high traffic sites. It is very interesting that it only requires small optimizations here and there.

One thing I’ve found in common with all large sites and that should be pretty obvious, is a PHP compiler cache and some type of caching system. Some of the more popular ones are APC, Bware Afterburner, Turck MMCache, and the Zend Accelerator. PHP caching systems are easy to write and can speed up template calls a ton.

You can speed up your site by using output buffering. What this does is use writev() instead of write(). The write() calls were sent to apache as 4kb buffers, where as the writev() calls aren’t.

Another speed up can be accomplished by setting Apache’s SendBufferSize to PageSize. This allows the page to be handed over to the kernel, to be sent, without blocking.

To reduce bandwidth, you may want to look into gzipping the contents of your page. I have seen this shrink 80gb backups down by almost a third the size, except for when most of the contents were images. So you should gain a lot for this if you can afford the overhead of the operations to compress your data.

There are also some simple thinks you can do to speed up your code. To speed up database calls, only query for that data you need. No need to SELECT * when you only need to SELECT id. You should also only query a table once. Get the data you need from it and store it, don’t query it again.

If you are using PHP5 or higher, you may also want to use MySQLi. This new MySQL API is much faster than the old API and includes both a functional and OOP interface. Most applications can be easily converted to use it. Plus, you get support for prepared statements and bind statements.

Optimization can also be made during the design of your database. Make sure you realize the differences between MyISAM and the InnoDB storage engines. MyISAM is very efficient for either very high volume writes or reads, but has table level locking. InnoDB has non-locking reads and row level updates, plus high concurrency.

You may also want to cache query results if they are not expected to update as often. An example I often use for this is CMS systems. Why query all of the blocks you want on one page, when you can cache the results of the original query for 6 hours and have them quickly accessible? Plus, if the owner of the site changes them, just clear the cache…

Now, back to what I’ve been up to. Besides reading up on the above, I have also been messing with my new project for the last two weeks straight. It is amazing how many hacks IE5-IE6 requires. I know I’ve used at least four to get my new site to display correctly. While the thing worked in Firefox, Safari, Epiphany, Konqeror, Opera, and IE7 the _whole_ time.

I hope most people will like the design though. I have shown it to around 20 people on IRC, and only one person hasn’t liked it a lot. So I would say I’ve done pretty good considering this was the first site I had designed entirely in Photoshop and then converted it to CSS/XHTML by hand. The core work for this new project starts this week and will probably continue for the next few months to a year.

Reference for high volume PHP: http://www.oreillynet.com/onlamp/blog/2006/04/digg_phps_scalability_and_perf.html

How do I roll? I roll with PHP/6.0.0-dev.

Thursday, March 23rd, 2006

I’ve had one insanely sweet idea for a website last Sunday. So after I got home today, I worked on building a php6 installed. I must say it’s not easy. I could not get the direct cvs checkout to compile correctly. It seems to me that flex and yacc weren’t generating the parser and I didn’t feel like fixing.

So I headed on over to snaps.php.net and downloaded a prebuilt cvs export. After installing at least 15 libabc-dev packages via apt-get, I was ready to build. So I started it and saw something about ICU. Well it turns out, the Ubuntu package isn’t up-to-date enough. PHP 6 requires ICU 3.4+. So I had to compile all 8.5mb of that code. Make sure that you run ./configure like this on ICU (according to the one thing I found on google about it, let me know if it works differently) ./configure –prefix=/usr/local/ –disable-threads
Here is what I build my PHP 6.0.0/dev install with:

./configure –program-suffix=6 –with-apxs2=/usr/local/apache2/bin/apxs –enable-openssl –with-zlib –enable-bcmath –with-bz2 –enable-calender –with-curlwrappers –enable-dba –with-inifile –with-flatfile –enable-exif –enable-ftp –with-gd –with-gettext –enable-mbstring –with-mcrypt –with-mhash –with-mime-magic –with-mysql –with-mysqli –with-unixODBC=/usr/ –with-readline –with-mm –enable-soap –enable-sockets –enable-sysvshm –with-tidy –with-xsl –with-icu-dur=/usr/local –disable-mbregex

Now, I’m off to mess with my long wanted namespaces in PHP.