Articles in the ‘Ruby on Rails’ Category

So long LiteSpeed, hello former Soviet Union - nginx

Thursday, June 5th, 2008

Its official, we’ve defected to the Russians.

I really like litespeed, mostly because it has a simple web interface to manage your virtual hosts, environments and all their settings. I’m seriously over a shell console and typing, programmers really need to get a clue about the power of interface design and a mouse…

Anyway, we did an minor upgrade to rails 2+ and some of our apps just wouldn’t start under litespeed anymore, but the mogrels were fine, so we decided to dump litespeed and run with nginx.

Scared of the install, setup, configs and options at first, I decided to make a night of it, I bought a case of redbull and Heineken and sat down ready be confronted with lots of issues to fix and a massive learning curve to get over.

Turns out I was finished in about 15 minutes – on my development environment, and in 10 minutes more my staging and productions servers we’re also up and running on nginx – with clustered mongrels.

So I put the redbulls back in the fridge and cracked open the Heinekens ;)

Anyway, yeah, nginx is surprisingly simple to setup and use, it apparently can get complicated but I didn’t see any of that. Our local dev server was running in about 15 minutes with a 5 mongrel cluster, nginx is using next to nothing and its all running beautify, don’t know why I never used it in the first place… actually I do, because everywhere said it was a bitch to setup and use… litespeed was harder!

My verdict is to use nginx over just about anything else, I’ve used apache, litespeed, lighthttpd, and some others, nginx kicks all of them in every area.

Application development team for $40 a week! Believe me?

Wednesday, March 19th, 2008

Have an idea for a web application? Want to invest in a real online venture? Something custom built to actually take on players in the market?

To build something substantial realistically costs thousands every month in development fees.

Let’s break down a professional development team, such as ours.

To develop a business application to the high standards that we have to for our clients, we have the following staff in house:

A Systems Architect, Project Manager, Programmers, Designers and an accounts person to manage the billing.

Of course they all aren’t fulltime on 1 project.

I’ll break down the % of time spent on an average 4 month project by each team member.

1 Systems Architect: 20%
1 Project Manager: 20%
1 Programmer: 100%
1 Designer: 50%
1 Account person: 10%

Our apps are all web based apps, hosted either internally or externally (intranet / internet), so there’s a high level of input from a designer who handles the interface design and xhtml etc.

This should be typical for any midsized development house. Let’s take US rates for staff and break down what a project would cost, and also look at the % per project.

Systems Architect: $100k – 20% = $20k a year, about $7k in wages for 1, 4 month project
Project Manager: $80K – 20% = $16k a year, about $5k in wages for 1, 4 month project
Programmer: $60k – 100% = $100k a year, about $20k in wages for 1, 4 month project
Designer: $50k – 50% = $25k a year, about $8k in wages for 1, 4 month project
Accounts: $45k – 10% = $4.5k a year, about $1.5k in wages for 1, 4 month project

So in total, in wages alone, for 1, 4 month project the cost for a company to develop an application is at least $40,000!

Plus, if this company is a contracted company, than they need to add profit and cover other costs, looking about $100k plus.

If you were to shop the project around and found a lone ranger, a 1 man show that can do it all, to cover his own wages for 4 months is still around $20k, and you would realistically expect less development done in that time since their time will be spent on other things, management, architecture, design, client updates, billing etc. I’d expect 3 days of a 6 day week of actual programming.

So how can I possibly justify my topic of a whole development team for $40 a week? Where is this crazy and bullshit deal?

Well there isn’t one. Not yet. Not that I know of anyway.

I can however divulge that I’m considering it…

I’m a systems architect and project manager for our current projects. We also have another project manager on staff, a designer, some ruby on rails programmers and some other general staff for accounts, and support.

There’s a bunch of projects that I want to build and I’m willing to open my team of developers to outsiders in exchange for their expertise, industry contacts and their own network of resources.

On top of that a requirement would be to share the development costs.

I can afford to reduce development costs to as low at $40 per week, on the proviso that there are 10 people investing in the application development.

So my thinking is that I’d invest in at least 3 shares minimum, and put the other 7 shares up for anyone to buy into at that $40 per week.

Why?

Well, I can afford to develop my own projects, and we do. But that’s what we do, we develop applications, we don’t necessarily have all the greatest industry contacts, networks of websites with thousands of users every day or things like that.

We can build businesses but we don’t have the time to market them, I’ve done marketing before professionally and I understand the resource requirement and time that’s really needed to make a web business work, and that’s not time well spent for a team like ours.

So I’m willing to open my team up to outsiders to own a portion of a business and in exchange for our super low development costs / super cheap investment, I’d only be accepting people who can offer what we don’t have, that marketing and promotion side of things.

Honestly the money for development isn’t an issue, but it covers my team costs and re-assures me that the people involved are dedicated to the cause; they have a financially invested interest in what’s going on, I would want to be partnering with people who have the resources and traffic to promote whatever it is we build successfully.

At the end of the day it’s about making the development successful, I wouldn’t be profiting from the development, so it’s in my best interest to partner with worthwhile people so me, just like you can profit from the business itself.

As for what we would be building, well I’m undecided. I have a lot of ideas, but who says it has to be one of my ideas? If someone comes along and has a good idea and is keen for what I’m proposing, then we might run with that and see if we can round up some other people to invest in it.

Anyway, just been a thought of mine, thought I’d blog about it.

Client work pays the bills and more, but I’m not into doing client work forever, we’re building our own apps and I’m defiantly interested in expanding that scope.

I’d be interested to hear some feedback on what people think about it all.

We’re all having the same problem with rails hosting

Sunday, March 16th, 2008

I think the biggest problem with ruby apps is the hosting.

PHP is so easy to host, you can upload it almost everywhere since mod_php is usually deployed by default with apache and php is deployed with every server now days.

Problem with Ruby is that it *can* be memory hungry and there’s ‘installing’ to do on the server side to get it up and running.

On top of that, web hosts either don’t support it, don’t support it well, or charge a lot to support it.

You can pick up an average ruby hosting plan with a plesk or cpanel control panel etc etc, but it’s going to be slow, not only because you’re on a virtual hosts - shared environment but because it’s not setup right, not load balanced and what not.

Just because it says FastCGI doesn’t mean its fast, Lighttpd isn’t all that light, and using a VPS and still using a control panel like plesk to handle your rails isn’t going to solve any issues.

This is where I think Slicehost is *almost* the perfect host for rails projects.

You can easily setup a couple of different slices (virtual servers) in a few minutes, and install SQL on one, and litespeed on the other.

Only downside is that there’s a lot of manual work to get it all 100%, not only on the server side, but on the client side.

Setting up your Capistrano, and other local tasks take time.

If Slicehost dedicated a side of their business to rails deployments, providing Capistrano recipes, deploying servers with litespeed and rails etc pre-installed, you know, like 5-6 different deployment configurations to choose from to get up and running, that should cover the most of what people are after.

Right now most non linux technical people are stuck either learning how to do all these things in linux which is time consuming, and frustrating at times, or people are stuck paying large sums for overrated hosting.

Mediatemple charge like $20 for 64mb of memory, mosso charge $25 for 128mb of memory and engine yard are off the scale with $990 per month + $690 setup… Not to mention engine yard’s $125 per month for 1gb of backup space!

‘Grid’ hosting, load balancing and what not isn’t all that hard to do, and it’s not terribly expensive, I think engine yard are overcharging a bit, but that’s my opinion.

If I ever got into hosting, I’d do the same as slice host but dedicated to ‘LAMP’ deployments on virtual servers, setup a grid over at cari.net and use 3tera to manage the virtual servers.

4 servers for a rails application?

Saturday, March 15th, 2008

Well 3 + a local dedicated development server.

For some people it may be overkill, but I see it as good planning and future proofing.

I run more than 1 rails application too, actually deploying upwards of 20 total over the next 2 months, so I need a dedicated area to store repositories (SVN), and it’s defiantly good practice to separate out the sql server from the rails server.

And as far as cost goes, it’s not much. Slicehost offer slices from as low as $20. So if you’re only getting started you’re looking at $40 for 2 virtual servers, each dedicated and saleable up when you need it.

I know a lot of people like to run rails apps in a shared environment, but if you do you’re stuck compromising on the speed of your app, stuck using low performance webservers like apache or lightty.

It’s well worth the money to run a couple of slicehost servers, and they are all yours, run as many apps on them as you want.

A few ruby on rails deployments starting this week

Friday, March 14th, 2008

I’m deploying a few new rails projects this week. The biggest issue I have with rails projects is the work that goes into setting up local SVN, Capistrano, an SVN server, application server, web server and a database server.

On top of all that you need to setup Capistrano to deploy to them all, and run some testing etc.

Overall it’s a 2-3 day process. But with the help of litespeed, it’s come down; litespeed has cut a good 6hrs out of it all in my opinion. Realistically it takes a lot of time to do it right, and to test it.

Not to mention the long term advantage of running litespeed, - load balancing, scaling and memory management.

Sure if you really wanted to you can get up and running in under an hour.

But to produce a solid development, staging and production environment with the right setup and infrastructure to last more than a month, it takes time.

I think I’ve put together a nice process to handle it all, I’m going to spend the next few days going through the whole process again from scratch, and I’ll be documenting it, so I’ll probably post it.

The setup I use server wise is:

  • 1x Local development server (Ubuntu 7)
  • 1x hosting account for SVN (I use a media temple grid service account)
  • 1x 512mb slice from slice host (dedicated virtual server, saleable up or down at anytime) for the rails application(s)
  • 1x 256mb slice from slice host (again, dedicated virtual server saleable at any time) for mysql and phpmyadmin.

The slice server virtual servers are also Ubuntu 7.

And as far as software goes, I’m using the normal subversion, ruby 1.8, and what not.

My main difference, and the main difference with everyone when it comes to ruby apps is webservers, I’m using litespeed.

I’m amazed why more people don’t use it.

Go and read about it. I’ll post more about it later. It really kicks the crap out of apache, and nginx.

It runs php 50% faster than apache. And it runs ruby on rails super fast too, and with less memory used. Far less.

Todays Next Mission: Installing LiteSpeed for Ruby on Rails on SliceHost

Sunday, March 2nd, 2008

Ok so I’ve decided to use LiteSpeed as my web server over apache, lighttpd and nginx.

Why? Even tho most rails developers are moving towards using nginx and a mongrel cluster or something similar, I like what litespeed are doing, and the foundation behind it.

Unlike the other systems, there’s a company behind them that you can call on for support – it’s a commercial product, so bugfixes will be regular and of urgency and things will keep evolving.

Nginx is mostly in Russian still and lighttpd doesn’t have much power.

Early on in my research I cut lighttpd out as an option totally, it’s really slow and just not what I want.

Other considerations were memory usage, not only of the webserver, but of the mongrel processes.

Mongrel can use a fair bit, so for us, hosting 20+ rails dependant sites and having all those extra mongrel processes staying alive without them being used is a big memory load, this is where I start to like litespeed a lot over the rest.

You see with Litespeed, it controls the mongrels direct with an api that’s a ruby gem, it will load the mongrels automatically when they are needed and shut them down when they aren’t, which is also good if your app has issues or memory leaks because it’ll start fresh again soon enough.

Also, having mongrel tied in to litespeed, there’s one less layer to stumble through, with lighttpd, apache or nginx there’s 3 ‘layers’… the web server, the mongrel and then your app. With litespeed, it’s just it and your app.

Next major win is that litespeed has a really good web interface for controlling it all, the virtual host for your site, the integration, the mongrel processes, the whole web server and all. So no more digging through config files on linux and hours of shell usage to get things going, you just use the slick web interface, which also displays real-time stats and logging.

Even though litespeed is commercial, they have a free version available that will handle most people’s needs, if you have a very high bandwidth site then you’re probably making cash so if you need a license to handle more than the free 150 simultaneous connections it’s only about $30 a month to handle 300 or more I think.

Anyway, there’s been a good debate on ruby forum about it all not too long ago…

http://www.ruby-forum.com/topic/137579

Aside from all that, installing litespeed is super easy, slice host have a 3 step manual on their wiki.

http://wiki.slicehost.com/doku.php?id=install_litespeed_on_ubuntu

After those easy steps are done you need to setup your rails app in the webserver – so you’ll need to create a virtual host, similar to apache but also with linking in the mongrel functionality.

Also, don’t forget that you need to setup your dns in the SliceHost control panel too.

To setup your virtual hosts, best bet is to follow this manual

http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:ruby_rails

Anyway, I did all this already on our local box, I’m doing it now on slicehost, will post about any differences to the manual if I have problems.

Todays Mission: Installing RoR, MySQL and LiteSpeed on SliceHost

Saturday, March 1st, 2008

Ok so I’ve moved hosts for some of our projects and sites.

This is a pretty big thing, at the moment we have a dedicated server with LayeredTech, a VPS with MediaTemple and 2 GridService accounts with MediaTemple.

It’s getting a little messy, so I’m consolidating everything to a MediaTemple VPS and a Slicehost (my new account) 1024 slice.

Forgetting the rest of the move for a bit, and the reasons behind it, let’s talk about slicehost.

I’m 1 day into my hosting experience with them at the moment, and so far I’m learning a lot, and wondering if this was the right choice.

I’m familiar with Linux to a good extent, I’d rate myself a 6/10, I’m no guru but I can do everything we need without any dramas.

The thing with slicehost is that there’s no web control panel as such, there’s no cpanel, or plesk, no way to add domains to an account, no simple web hosting. You have to know what you’re doing and you really have to have a good grasp of Linux before you even think of hosting with them because most of your time will be spent in shell.

Somewhat like MediaTemple where you have a control panel, you can manage your slices and general bits from a web interface, you also have DNS control, but that’s it. No email or anything. It’s very ‘heavy’ on the manual labour side of things, as far as reading and typing to get things setup, not your typical institutive user interface with 3 clicks to get a site up and working.

So all that scary part aside, there’s lots of documentation around for slicehost, so it’s not too bad.

Also, after purchasing my slice it was operational in less than 2 minutes.

At the moment I’ve just installed Ruby, Rails and MySQL, so far so good.

To get this far I’ve used the slicehost wiki on how to gets started with your new Ubuntu slice…

http://wiki.slicehost.com/doku.php?id=get_started_with_your_new_ubuntu_slice

I picked Ubuntu mostly because we run Ubuntu servers for development internally, but it’s also very well supported by Slicehost.

The Ubuntu wiki is pretty big for slicehost, check it out here http://wiki.slicehost.com/doku.php#ubuntu

Next on my list is to get LiteSpeed installed.

Building web applications from a business owners perspective: the reasons why we use Ruby

Friday, February 29th, 2008

That’s something we do here, (my business), we build web apps.

A fair while ago now I had to make a decision which way to go for web app development, language wise.

I ended up choosing ruby.

Why?

Well not only does ruby have a really cool framework, Rails, but the language is very easy to use and learn.

The main reasons that swayed me to build a team of ruby developers over php and asp

  • No more SQL… Yeah, no more having to write sql. For a programmer that’s a shocking statement. But I’m not a programmer. I’m a business man, and as a business man I need apps built quick, I need fast development cycles and cutting out the whole sql side of things defiantly does that.
  • Ajax is built in. To do lots of fancy and cool java (ajax) things, you typically have to code it all yourself, which means as a business person I need a java programmer on staff too, but ruby has ajax helpers that do the majority of the java code for you. Again a time saver.
  • Rails environments. Rails can run in different environments, so development, test and production. This also means there are 3 different databases, it’s a big thing to explain, but it’s fantastic.
  • Version control. This leads from that last point almost, and sets up the next, we use SVN and Capistrano to manage versions and deployments, a new version gets deployed and then migrated.
  • Migrations. New additions to the database and system can be deployed and migrated to the test environment on the server (beta pretty much) for testing, if it looks all good, you can then do a production migration, so migrate all the updates to the production environment with a few lines in your shell on the server. Saves taking down a site, manually migrating databases etc etc etc. This does it all for you.
  • Reverse Migrations, again, I can’t mention it enough, if you push something into production and there is an issue, you can roll back to your previous version with 1 line in your command shell. This rolls back everything – files, new columns in databases, everything… You can then fix the issue in the test or development environment, and then deploy the new version. Super cool, all with no downtime.
  • MVC framework, models, views and controllers are fantastic, that’s a framework advantage and most developments use frameworks now days, php and asp, but rails is still very nice and I think does a great job of it. Easy for any developer to jump in and start working without having to read comments or a manual, or having to search through random code and files.
  • Easy to learn, I’ve found it one of the easiest languages to learn, which is great when brining on new staff, if you take on php or asp coders you need to be prepared to take a risk on how good they actually are, theirs skills overall might be alright but their actual coding ability could be average. With ruby, it takes lots of the coding out of the coders hands, an example is sql, you don’t have to worry that your php programmer is really bad at sql or not, or he might know sql backwards but be average with php. At least with ruby you know the developer is skilling up more and more on ruby and other languages or systems.
  • Gems are very nice, gems are like plug and play add-ons for your apps, you can install a gem with 1 line of text in your shell and right away you can start using its functionality. A gem can be big or small, it’s a whole application in itself, your app basically interacts and uses a gem like an API, but it’s all wrapped in together and deployed with your app.

Anyway, there’s lots of things you can compare and push back and forth about why one is better than the other, personally ruby on rails makes more business sense to me, it’s a rapid application development language and framework, it’s an actual object orientated language not a scripting language like php, we can build, fix and maintain fast, and still deliver a quality product, which is all that counts in my opinion.

Programmers will always want more control and flexibility with their language, they want power etc, ruby takes lots of it away from them so they assume its inferior and not worth changing from their super powerful asp or php, in reality that matters in certain conditions, when you need to really write an app well to achieve maximum performance etc, or to do extremely complex things.

However we’re not doing extremely complex things, and as far as power goes – servers are cheap, and we use grid layer servers, so scalability and performance isn’t an issue. For us rapid development and easy manageability is key.