May 25th, 2008
I build a lot of Rails apps on a regular basis and each one I add to my server takes another bite out of my limited resources. The way I’ve traditionally setup a new Rails app was using a Mongrel cluster. I found it to be a lot more reliable and faster than the fcgi approach people use to use (and some still do). The downside to setting up a few dozen Rails apps on your server with each running a Mongrel cluster is that it eats up all your memory. One of my sites is starting to get a lot more traffic than it has been in the past and its putting additional strain on the server. As a result I decided to find an alternative to Mongrel. I’ve tried searching for alternatives in the past but everything sent me back to Mongrel. Until today of course when I came across Jamie Flournoy’s blog about mod_rails.
Excited for an alternative to raising a pack of resource hungry mongrels on my server I installed the gem and tried it out. It was exactly what I was looking for as far as ease of use straight away. All I needed to do was stop a mongrel cluster and simplify its virtual host directive in Apache to leave out the mod_proxy_rewrite and the other wonky rewrite rules. The first app I tested went smoothly but suddenly the server started misbehaving. Resources were being eaten and it wasn’t clear what was doing it because the app I was testing with is behind an Apache password and I’m the only user. I ended up having to turn off the mod_rails to get my system back in control. The problem turned out to be that by default mod_rails tries to test if your virtual host directory is a rails app or not. I have a few apps that I tossed in an instance of Wordpress into a blog directory inside my rails app directory. I found it convenient to toss them all into the same directory since its all the same website. As a result mod_rails was doing a ../ check to see if the blog directory was a rails app which it decided it was. That’s where the craziness came in because its a php application. Anyway, the quick solution was to move the blog directory out of the Rails app directory.
Other than that my memory usage is way down. I’ve migrated all my low traffic sites to mod_rails and I’m happy with how they’re performing. There is a little delay on the initial load of the app but subsequent calls are quick because its already loaded. I can wait an extra 2-5 seconds for my low traffic apps to load in exchange for hundreds of extra megs of free memory.
I haven’t moved over my higher traffic money making sites yet and I’m not entirely sure I will until I’ve tested mod_rails a bit more. I’m extremely happy with the results thus far though.
Related Posts: Goodbye (notso)fastcgi, Hello Mongrel
Tags: Apache, memory, mod_rails, rails, resources, ruby, scalability
Posted in Apache, Frameworks, Linux, Ruby on Rails, Web Development | No Comments »
May 17th, 2008
Rails page caching is pretty simple to get working usually. If you’re new to caching in Rails, there’s plenty of good tutorials out there to get you up and running in no time like this one from Rails Envy. Rails is a resource hog and on my servers I’ve got about two dozen apps running. Combined they use up most of my memory and on peek hours can push the server to the brink of disaster so caching is extremely important to keeping things under control. The last thing I feel like doing is having to offload some apps to another server. I’ve used fragment and action caching with great success but wanted to use page caching on a new app I am building. The problem I have been having was that the pages were being cached properly but Apache wasn’t serving them up. I tried a whole slew of different tweaks to my Apache configuration before finally finding the problem. I found the problem by including the following in my Apache configuration:
Using that debug information I was able to toy with the rewrite settings that were suggested by the many tutorials out there and find the problem. Most Rails page caching posts I found that used Apache and mongrel_cluster had a suggested rewrite configuration like this:
Now, this may be specific to my Apache configuration but what I found was that the rules weren’t rewriting to the correct urls. They were missing / and ending up relative. The way I fixed it was pretty trivial but took me some time to discover so I figured I post it. The solution ended up being like this:
I added some preceding /’s and removed the / after cache on the second rule since the $1 got translated with the /. This modified configuration got my page caching working properly.
Related Posts: Goodbye (notso)fastcgi, Hello Mongrel Problems with non-english characters in urls media='print'
Tags: Apache, apache rewrite rules, caching, mod_rewrite, mongrel_cluster, page caching
Posted in Apache, Ruby on Rails | No Comments »
May 16th, 2008
I’ve been reading a lot of news lately about this Yahoo / Microsoft deal that fell through. Now the latest is that some big share holders are trying to force the deal to go through by replacing Yahoo’s board. It just goes to show how Wall Street misunderstands the situation. Stocks increased on the run up to the deal deadline. After it fell through, Yahoo stocks slipped. Anyone with half a brain would have picked up a few shares after the slip which is exactly what I did. Of course I’m not a 5% stake holder in the company but a few shares I do own and I felt like venting my frustration at the other vocal shareholders trying to force the deal with Microsoft.
Yahoo has long been in battle with Microsoft even from the early days with Hotmail. A deal with Microsoft would essentially devalue the Yahoo brand and have it lose respect among the geek community. Over the past year or two Yahoo has been growing its web business in the right direction. Its acquisitions of Flickr and Del.icio.us are just 2 examples off the top of my head. Those two names alone boost Yahoo’s appeal as a company which is why Microsoft is after them in the first place.
More importantly is their search technology. Despite Google’s dominance in search, Yahoo’s search engine has gotten extremely better over the past few years. Its results are typically much more accurate than Google’s in my opinion and they’ve been growing more and more appealing as an alternative to Google’s mythical magic search engine. Anyone who watches search engine rankings will tell you that Yahoo’s search results are much more consistent over time which makes it even more appealing. Not only that but SEO for Yahoo versus Google is more scientific and less voodoo. Its just another reason why Yahoo has been looking like its positioning itself more and more to become an extremely formidable online presence. Microsoft recognizes that and wants to low ball them before they secure their footing and get a steal on a buyout bid. The stockholders are on Microsoft’s side because they see a potential short term gain in stock value.
What they fail to see is that a Yahoo - Microsoft merger would essentially ruin any chances of a truly successful online presence for Yahoo and Microsoft. Microsoft has proven itself incapable of bringing anything worthwhile to the online arena even with past acquisitions of online businesses. Its ultimately a dooms day deal for Yahoo that’s being pushed by a few big stockholders who want some quick cash and have little interest in the long term success of Yahoo’s technology. I’m behind their technology and support them but selling out to Microsoft is likely going to sour the support Yahoo’s built up in recent years and ultimately fail as usual in the hands of Microsoft. Microsoft is a has been. Ask any kid who’s used a Mac before. They’re desperate and see the writing on the wall. They want to prolong their demise by purchasing promising web companies.
My guess is that Microsoft has wooed these stockholders privately in a lobbying type effort. Their thinking is that instead of raising their bid that they’ll woo a few big stockholders to replace Yahoo’s board and get their low ball deal for the company. Its typical Microsoft at its best. Either way, Yahoo’s stock is destined to go up whether they sell or don’t sell. No sale means they continue their forward progress and continue to build their momentum in a positive direction. I’ll likely keep my shares in that case. Sell and I’ll likely sell my shares shortly before the acquisition so I don’t end up with a loss at the end of the day. I’m no day trader but those are my thoughts as a web developer who’s seen these two companies have their better days.
Related Posts: Extortion via Sender Score Certified Google algorithm update My beef with the Google god
Tags: microsoft, stocks, yahoo
Posted in Google, Other Websites | No Comments »
April 22nd, 2008
I’ve been working with a client to optimize parts of their Rails application. The problem is that a method in the app does some simple updating of a few model objects but because the model has so many relations it goes through a ton of unnecessary callbacks. There are issues related to data concurrency which means you have to do the callbacks but in this particular situation there won’t be any concurrent updates to the data so the callbacks can be omitted. The solution to the problem was trivial when using the save_without_callbacks Rails plugin. Just adding a simple:
before the update_attribute reduced the number of SQL UPDATE queries from 90 to 8. Lesson learned. If you need to skip model relation callbacks on save this plugin is for you. Be careful about data concurrency issues though.
Related Posts: Speaking in Tongues Inheritance in Ruby on Rails Class table inheritance problems
Tags: rails, rails optimization, rails-plugin, ruby
Posted in Database, Ruby on Rails, Web Development | No Comments »
April 21st, 2008
This isn’t really the proper forum to be blogging about political preference, however, I stumbled upon a key difference in the three presidential candidates Obama, Hillary, and McCain with regards to the language they chose to program their campaign websites with. A quick browse through the links on the McCain site shows that they use ASP as you can see from this link:
http://www.johnmccain.com/ActionCenter/registertovote/information.aspx
A similar search through Hillary’s site confirms the same. They use ASP and you can see from this link:
http://www.hillaryclinton.com/video/158.aspx
Now, saving the best for last, Obama has a smarter approach to technology and uses PHP instead as you can see here:
http://www.barackobama.com/index.php
Based solely on programming language choice for their web development which candidate would you choose? Given that I’m a Rails and PHP developer (albeit I once programmed in ASP for a paycheck) I think I’m going to have to go with the better language choice. It says something about where your head is.
Related Posts: Impressions of PHP 5 An awesome free font website Easy website color palettes for the artisticly handicapped programmer
Tags: asp, hillary, mccain, obama, php, president
Posted in Reviews, Web Development | No Comments »
April 18th, 2008
I’ve been working with one client for several months now and they are extremely pleased with the results I’ve produced for them thus far. Here is a snapshot of the monthly analytics data for the site over the past year. You can get a larger view of the graph if you click on the image.

I started working with them in July and by August you can see that their traffic more than doubled. From July to now, I’ve continued to work with the client on increasing rankings through seo, link building, and improving visitor retention. The result is that their natural organic search traffic has seen an increase almost 10 times what it was, from 1,800 to 17,000. I’m pointing this out because I like the latest Google Analytics monthly graph view. It really helps in showing trends over time and its encouraging for clients to see the upward results from my seo work.
Related Posts: A quantitative look at SEO vs. PPC
Tags: analytics, Onomojo, search engine optimization, SEO
Posted in Google, SEO, marketing | No Comments »
April 17th, 2008
Its been a long time coming but we’ve finally got our new site design finished for Onomojo. We’ve also expanded our services to include graphics design, logo design, web design, and a whole slew of other graphics related services. That’s in addition to the services we already provided which were primarily programming, seo, and marketing related. Here’s a screenshot of the new design.

Related Posts: SEO, online marketing, and web development Free link exchange management service Trac Design Spec Modification
Tags: graphics design, logo design, online marketing, Onomojo, SEO, Web Design, Web Development
Posted in Apache, Database, Frameworks, Linux, Other Websites, Perl, Reviews, Ruby on Rails, SEO, Web Design, Web Development, marketing | No Comments »
March 4th, 2008
I’ve been through the ropes when it comes to SEO and PPC advertising (particularly with Google’s Adwords). Clients come to me either looking for SEO or online marketing solutions. Their objective is obviously to increase their sales and they want it to happen yesterday. The first thing I look at is where a site is currently ranked in search results for their targeted keywords before beginning any SEO or PPC campaigns. I like to also take a look at their Google Analytics data to see what’s already working well for them and to get a perspective of the volume of traffic they’re dealing with. Some business have none of these things setup and are simply trying to make a push to increase online revenue. Whatever their motivation the objectives are all the same and the same techniques apply. Except, however, for my recommendation for PPC ads.
Small businesses which don’t get much online traffic are usually looking for a quick fix and instant gratification. I usually take the time to explain the benefit of SEO and link building to these companies but in the end they usually choose PPC advertising. I’m not against PPC ads but I do have a pretty quantitative reason for trying to dissuade some of my clients from pursuing that route. From my experience, PPC ads only work if you have a high return on a product that has a high conversion rate per click. In essence a high ROI. The problem for many small businesses is that they sell low dollar items which themselves produce a small profit margin.
Lets take a small handmade soap manufacturer as a perfect example of a small business looking to expand their sources of revenue by setting up a shopping cart. A company like this might make a dollar on each bar of specialty soap sold. They aren’t likely to have huge resources like a large technology corporation so their budget for the project is relatively small. Lets say less than 5k USD. Part of that covers development costs and the rest ends up in limbo while I exude the benefits of SEO over PPC advertising to the client. From the perspective of a business if someone tells me to spend a few thousand dollars and it’ll pay off in maybe 6 months but they can’t guarantee first page placement my natural business sense tells me to tell this person where to go. My alternative is to pay per click advertising which will result in instant traffic and likely increase my sales immediately. The choice is simple in that regard and its why many small businesses with little understanding of online commerce end up abandoning their get rich quick online schemes.
Lets dig a little deeper into PPC ads. Lets assume a bar of my handmade soap costs me $3 and my typical order contains 3 bars of soap. Lets also assume I make $1.50 off each bar of soap I sell. Those numbers are pretty realistic examples. I now want to start an online marketing campaign and put in 3k USD to PPC ads for a month. That means I need to sell 2000 bars of soap in a month and have about 666 orders with 3 bars each on average. If we stretch those orders out over the entire month then I need to get about 22 online orders a day to simply break even with my PPC advertising campaign. Now lets look at the budget I have allocated for the month, $3,000. That’s about $100 a day. Lets assume that with my amazing skills I’ve managed to optimized my Adwords campaign so well that I’m getting an average CPC at $0.40. That will give me about 250 visits a day just from my Google Adwords campaign. If 22 of those 250 visitors placed orders that would make my conversion rate 8.8%. Depending on the industry that’s a pretty high conversion rate for online sales. Now take a look at what we just went over. This looks at what we need to just break even and we had to make some incredible assumptions like our amazing CPC at $0.40. A average CPC of $0.60 to $1.20 is more realistic for the targeted keywords but we gave ourselves the benefit of the doubt for this example. We still needed a 8.8% conversion rate which isn’t too probable. Its an example where some simple upfront analysis of the numbers will tell you that my $3,000 is better spent doing some SEO and link building so that I can get natural free search traffic that will last longer than a single month.
Lets take an example of a high dollar product, travel. People spend about $1500 on a travel sale and per sale I may make on average 10% or $150. The example above needs to be modified to have an average CPC at $2.00. If I need to make $100 a day in sales it means I need to make just 1 sale a day or 2 every 3 days. If I’m spending $100 a day on ads with an average CPC at $2.00 I’ll get about 50 visitors a day. If I need just 1 sale from those 50 visitors that’s a conversion rate of 2% which is certainly much easier to get than the 8.8% I needed from selling soap. This campaign has a high likelihood of succeeding and will probably be well in the black at the end of the month.
Travel has a high profit margin and requires a low conversion rate which is why PPC campaigns work for it. Soap has low profit margins and requires a high conversion rate to simply break even so a PPC campaign isn’t likely to succeed. My soap business will end up negative at the end of the month and I’ll likely be bitter at the waste of the small investment I made towards PPC ads.
In summary, SEO is the way to go for small businesses selling products with small profit margins. Its a more calculated and well thought out method of generating sales online. The benefits may take time to show but the payoff is that your online business may actually succeed. PPC ads on the other hand will have you bleeding money with little chance of ever turning a profit.
Related Posts: Quantitative evidence of my SEO effectiveness
Tags: adwords, cpc, online marketing, ppc, SEO
Posted in Google, SEO, marketing | No Comments »
February 28th, 2008
The other day I noticed a pretty significant SEO related problem with using a built in Rails construct. I noticed a problem when I started getting application errors that were letting me know that the user agent was none other than our friendly Googlebot. A closer look at the app shed light on a problem you may not have even expected. When using
it will take a look at the HTTP_REFERRER and redirect the user to that url. The problem, however, is that Googlebot doesn’t send a referrer and neither do a whole bunch of other search engine spiders. The result is that when they visit your site they get a nice 502 server error because Rails raises an exception. It doesn’t know what url to redirect to so it send a 502 error. Googlebot then sees your site as a bunch of 502 errors in the situations where you’re using redirect_to :back. Take a look at the Rails API and you’ll see the last line clearly mentions this.
The solution is to catch the RedirectBackError the redirect_to raises when there’s no referrer. Its a simple fix but one you need to be on the lookout for or else you might end up with a few 502 errors giving you bad mojo with the Google gods.
Related Posts: Impressions of PHP 5 Speaking in Tongues Ditching Mongrel for mod_rails
Tags: 502 error, googlebot, rails, rails api, SEO
Posted in Google, Ruby on Rails, SEO, Web Development | No Comments »
February 8th, 2008
I’ve made the leap and I’m starting to use Rails 2.x for all my apps now. Overall it was a pretty smooth transition over to 2.x. One thing I noticed immediately after running the scaffold generator, ./script/generate scaffold Something, was that the layout template was named something.html.erb. What’s this new .erb extension I thought to myself. I did a little searching and found Ryan’s Scraps where he explains the reason for the change. Its all about semantics. Notice the post date was back almost a year ago.
It makes me want to reflect about Rails in general. Am I really a year behind here? I’ve been developing in Rails for a few years now and love it for all the right reasons. One of the most important facets the framework offers is its constant adaptation to better ideas. The Rails project seems to be one of the most fluid projects I’ve ever seen in terms of embracing new and better techniques for doing things. I think that simple fact is what gives it an edge.
In this industry, a developer has to constantly stay ahead of the curve and always be thinking of how to do things better. I end up getting into the trenches and working on a project for a while but by the time I come up for air I’m doing things the old way already. Here I am upgrading my skills to Rails 2.x and I’m already feeling like I’m old school. Rails apps move quickly and if you don’t pay attention you’ll just as quickly get behind. Other frameworks seem like they’re more consistent over time and as a programmer there’s often little to learn on new releases. Rails is different. It forces you to reconsider what you already know. Take routes for instance. Now everyone is using RESTful routes. You learn the old way and they reinvent it under your noes. Its a beautiful dynamic that forces me as a developer to stay on my toes and to constantly improve my own skill set.
One problem that I face, however, is the complexity of managing multiple project across multiple Rails versions. Rails luckily allows me to freeze the framework into a project so my problem isn’t in incompatibilities. Its in the complexity that arises from having 20 or so projects all running different Rails versions. Some of my projects run older versions of Rails 1.x. Some run the newest 1.x version and even newer projects are now running 2.x. Sure you can say that I should upgrade all those projects but that works in theory. In practice, however, resources are limited and some projects have a priority over others. Time is limited so its usually spent where its needed most. Smaller projects fall through the cracks and sooner or later they seem like old legacy apps even though they’re only maybe a year old. I suppose its just another part of this industry: dealing with legacy systems. Not every legacy system can be upgraded to the latest and greatest. Of course the purist programmers out there want to keep everything current and doing every single best practice you can consider best. Practicality reins supreme though and resources will always remain limited. The best any developer can do is to constantly try to reinvent themselves and never close the door to new ideas. Once you become comfortable in what you know is when you’re going to miss the next big idea.
Related Posts: Desko one-to-many associations made easy with ActiveScaffold Open Source Keyword Tracker
Tags: legacy systems, project evolution, rails, Web Development
Posted in Frameworks, Ruby on Rails, Web Development | No Comments »