Categories
Programming

Running PHP applications on Heroku

These last weeks I’ve been working on trying to organize my domain names and web hosting accounts. I’m running this blog and several other websites on a VPS as a WordPress multisite. The other applications that I am running are small PHP applications. I’ve been looking into running the other applications on Heroku. By moving these away from my current web hosting account I can cancel that account and use it for domain names and their DNS control panel.

If you would like to try running PHP applications on Heroku I suggest you create an account and create a new app at the Cedar stack (for PHP support). Then sign up for an account at Amazon S3. I use Amazon S3 for their cloud storage and keep my transfers and data (less than 5 GB) beneath their free tier to keep my costs minimal. To stay at Herokus free tier you can’t store more than 5 MB for the MySQL database and not more than 10 000 rows on the Postgres database. The PHP applications I’m running at Heroku is using MySQL as a database backend and databases at Heroku can get costly fast, especially when using several dynos.

If you’re not running your PHP application in the webroot, take a look at https://github.com/winglian/Heroku-PHP for instructions on how to change the webroot at Heroku.

Advantages

  • Easy to deploy, my old hosting service didn’t support SSH access or any other way to do a proper deployment.
  • Cheap (maybe even free…?) for small applications.
  • Minimal maintenance since I don’t have to administer a VPS.

Downsides

  • If you start adding dynos, it gets really expensive.
  • Your Ruby on Rails applications on the free account winds down after idling for a while and has a startup time that feels like forever. That doesn’t happen for the paid accounts. This doesn’t apply on PHP applications though.

After doing this test run, I will definitely look into running this WordPress Multisite at Heroku instead of having my own VPS.

Categories
Programming

Inspect SQL queries generated by Ruby on Rails

I’m currently working on a rewrite of XCStorm, my website dedicated to crawling the web for news about cross country skiing.

Preview of the new filter system at XCStorm

I’m using Heroku for hosting and for development I’m running SQLite and for staging/production its Postgres (I know its bad practice to mix…). Anyway, I found myself in a situation where I needed to compare SQL queries generated by the ORM.

Create a file named .irbrc and put this into it:

ActiveRecord::Base.logger = Logger.new(STDOUT)

Afterwards, start your Rails console and enter your query.

The reason I’m mixing database adapters is because at this point it doesn’t matter since the data won’t be complex and its easier for my partner to setup and interact with the database.

Categories
Personal

Upcoming posts will be written in english

A couple of friends from San Jose State University complained that Google Translate didn’t do the content much justice so I decided to try to write new posts in english.