Welcoming Ruby 2.0

Today we’re happy to announce that the recently released Ruby 2.0 is now available on all of our servers. You can run Ruby 2.0 today as ruby2.0. Here it is on Web310:

$ ruby2.0 -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]

Ruby 2.0 comes with a number of new features, performance improvements, and built-in library changes.

One of the more prominent new features is an addition to the language syntax: keyword arguments. Sometimes known as named parameters, keyword arguments provide a more explicit way of using arguments and setting defaults. Here’s a little example:

$ irb2.0
irb(main):001:0> def greet(greeting: 'Hello',  name: 'WebFactioneers')
irb(main):002:1>   puts "#{greeting}, #{name}!"
irb(main):003:1> end
=> nil
irb(main):004:0> greet(name: 'readers')
Hello, readers!
=> nil
irb(main):005:0> greet(greeting: 'Howdy')
Howdy, WebFactioneers!
=> nil
irb(main):006:0> # you can even change the order
irb(main):007:0* greet(name: 'readers', greeting: 'Salutations')
Salutations, readers!
=> nil

For more details about Ruby 2.0, including a description of potential incompatibilities with previous Ruby versions, please see the official release notes. Try out Ruby 2.0 with your WebFaction account and, if you have any questions, join us in the Q&A Community.

Posted in General, Ruby | Leave a comment

A look at version control on our servers

Appending version_36 or final_2 to a file name is no way to keep track of different versions of files. Instead, we’re lucky to have a wide variety of version control tools at our disposal. And a webserver is no place to skimp on such things, so today we’re taking a look at version control on WebFaction’s servers.

If you like your version control centralized, with a single, authoritative repository, we’ve got you covered with Subversion. Both the Subversion client and server are available with your WebFaction account. For example, you can check out a working copy of the WordPress trunk with the svn command-line client like this:

$ svn co http://core.svn.wordpress.org/trunk/ wp-source

You can also serve a Subversion repository with the one-click installer. You can serve a Subversion repository publicly for open-source projects, or set up users to control access for private projects. Check out the Subversion documentation for more details.

If you like your version control distributed, where each user has a complete “clone” of the repository, then Git is a great choice. Each WebFaction server has the Git client installed, and serving Git repositories on the web is a snap with the one click installer. The client’s handy for grabbing code from GitHub, like the Django repository:

$ git clone https://github.com/django/django.git

Like Subversion, you can make respositories available on the web with the one-click installer. A single Git application can host mulitple repositories and can be configured for public access or per user access for private projects. See the Git documentation for detailed instructions.

An additional benefit of using a Git or Subversion application is that you can link your repositories to a Trac installation. Trac is a handy, open source project management tool that features a ticket tracker, wiki, and repository browser. For more details about using Trac with your WebFaction account, see our Trac documentation.

Of course, Git and Subversion aren’t your only options. It’s easy to set up other version control tools in your home directory. We have instructions for installing Mercurial and Bazaar clients, as well as publishing Mercurial and Bazaar repositories on the web with hgweb and loggerhead respectively.

So if you haven’t already, give version control a try with your WebFaction account. Let us know what you think in the comments, or if you need any help, join us in the Q&A Community.

Posted in Git, Server setup, Subversion, Trac | Leave a comment

Django 1.5 is here!

Today, the latest version of Django has been released. And we’re happy to make it available to you with the new Django 1.5 one-click installer:

Screen shot 2013-02-26 at 3.14.47 PM

Django 1.5 brings with it several major improvements, including:

  • A customizable user model. Now you can use you own model to store information about your users. Use it to ditch that 30-character username restriction, or to store first name and last name together in a single field.
  • The verbatim template tag. It turns off Django’s templating between the tags. Handy for using some JavaScript libraries, for example.
  • Experimental Python 3 support. Now you can start testing your Django application with Python 3, to prepare for the future of Python. Production-ready status will be here before you know it, when Django 1.6 is released.

Django 1.5 has a slew of other changes, too. Check out the Django project’s release announcement and release notes (mind those backwards incompatible changes), then give the new one-click installer a test drive. Let us know what you think in the comments and, if you have any questions, join us in the Q&A Community.

Posted in Python | 6 Comments

A look at databases on our servers

It’s a rare web hosting user that can get by without a database, so today we’re taking a closer look at how you can setup and use popular databases with WebFaction.

To start, the WebFaction control panel makes it easy to create databases, so there’s no need for any complex commands. You just pick out some details and click Add database (Check out the introduction to our new database management interface for an in-depth look):

A screenshot of the databases user interface

A database created with the control panel runs on your server’s shared database process. The shared server is more convenient than configuring your own and doesn’t count toward your account’s memory usage.

Different applications have different needs, so every WebFaction server supports both MySQL and PostgreSQL. MySQL is extremely popular and is used in several of our one-click installers, including WordPress and Drupal. PostgreSQL is growing in popularity and sports some exciting features, like procedural languages PL/Perl and PL/Tcl.

Once you’ve created your database of choice, it’s easy to connect to it and start storing data. Check out these documentation sections:

Although the shared database and the associated documentation is convenient, it’s not necessarily for everyone. That’s why we recently introduced a one-click installer for private MySQL and PostgreSQL instances. A private database is a good option if you’re facing problems with contention on the shared database or if you want to customize the database configuration.

And, of course, you can always set up and run a specialty database from your home directory on your own. For example, check out our instructions on installing MongoDB.

For more details, see the WebFaction User Guide page Databases. If you have any questions, let us know in the comments or join us in the Q&A communtity.

Posted in Control panel, General, MySql, PostgreSQL | Leave a comment

Ten amazing years, $100,000 giveaway!

[Update Feb 7th 9.30am UTC] Our birthday giveaway has now ended. We sold out in about 40 hours.

Today marks WebFaction’s tenth birthday: ten years of hosting, ten years of support, and ten years of working to provide a service that we can be proud of. Ten years ago WebFaction opened its metaphorical doors to the world, and though a lot has changed since then, including our name, we hope to be doing for another ten years what we’ve always done: our best for our customers.

To celebrate this milestone, we’re giving away $100,000 in hosting services to new and existing customers. Starting tomorrow at 2pm UTC, new and existing customers may receive a one-time credit added to their accounts.

New customers: just sign up from tomorrow Feb 5th at 2pm UTC and pay $9.50 for the first month (or pay for longer). $100 will automatically be credited to your account.

Existing customers: add one new service to your account from tomorrow Feb 5th at 2pm UTC (a 256 MB plan, 256 MB extra memory, or a 1GB plan) and pay for one month of that service, and you will receive the next three months of that service for free.

Each customer is limited to one credit only, and it is non-transferable and non-refundable. Once we’ve given away $100,000 in services, the promotion will end and we’ll update this blog post to reflect that. Be quick or you might miss out on the free services. If you don’t need them yourself you can refer a friend and earn yourself some affiliate rewards.

Here is the Twitter announcement and the Facebook announcement so you can help spread the word if you’re on Twitter or Facebook.

Thank you for our first ten years; we can’t wait to see what’s in the years to come.

[Update Feb 5th 2pm UTC]: The giveaway has started!
[Update Feb 7th 9.30am UTC] Our birthday giveaway has now ended. We sold out in about 40 hours.

Posted in General | 48 Comments

Introducing private PostgreSQL instances

In October, we introduced the private MySQL instance installer as a solution to the “bad neighbor problem,” where one user consumes too much of a server’s shared MySQL database’s resources. Today, we’re introducing the private instance installer for PostgreSQL.

Like the private MySQL instance installer, there are a few details to consider:

  • The private instance relies upon the server’s globally-installed PostgreSQL binaries and libraries. If a security problem is found in PostgreSQL, WebFaction will apply the appropriate patches and no action is required on your part.
  • On CentOS 6 servers (web300 and greater), the version of PostgreSQL is 9.1. On CentOS 5 servers, the version of PostgreSQL is 8.3.
  • The PostgreSQL configuration files are owned by your user account and the server process is run under your user account. This means that you have full control over how the instance is configured and when it starts and stops running.
  • When the instance is installed, a cronjob is created to make sure the instance is running. Every 20 minutes the instance is checked, and if the instance is down, then it is restarted.
  • When the instance is installed, a cronjob is created to dump all the of the instance’s databases to a file every 24 hours. One week old dumps are deleted automatically.
  • The private instance may consume hundreds of megabytes of memory, depending on the instance’s configuration and the volume of data stored. The memory consumed counts toward your account’s memory allotment  For non-trivial datasets, we recommend upgrading to a minimum of 512 MB of memory or using one of our new 1 GB, 2 GB, or 4 GB plans.
  • To move data from the shared database server to a private instance, please see our importing and exporting documentation as a model for migrating your data.

Starting today you can use the one-click installer with the WebFaction control panel. Let us know what you think in the comments, and if you have any problems, join us in the Q&A Community.

Posted in PostgreSQL | 7 Comments

New databases management interface

Today we’re proud to show you the newest update to the WebFaction control panel. We’ve upgraded the way you create and manage MySQL and PostgreSQL databases and users, as a part of our ongoing effort to make the control panel easier to use. We’ve made this two-minute video to show off how the new interface works:

The new databases interface is more flexible when it comes to creating databases and determining who can access them. In the past, database names were required to begin with your username and an underscore. The new databases interface throws that requirement out the window. Starting today, you can name your databases as you please. Perhaps more importantly, now you can grant a single user access to multiple databases, and more than one user may be granted access to any one database.

In addition to the video, we’ve updated our documentation to reflect the latest changes to the control panel. Let us know what you think in the comments and if you run into any problems, join us in the Q&A Community.

Posted in Control panel, MySql | 12 Comments

Setting up the reddit app without root access

We manage the servers for you which means that you don’t have to worry about setting them up and most importantly maintaining them. We provide a team of systems administrators who work around the clock to do things like applying security patches, monitoring servers, fixing server issues when they arise, building RPMs with new versions of tools and backing up your data.
For this to work smoothly we have to make sure that our servers are set up in a certain way (with some standard linux tools and some of our own tools) and it means that you don’t get root access to the servers. In practice this is rarely an issue because you can usually install anything you need in your HOME directory, even when the tools’ installation guides assume that you do have root access.

As an example we’re going to set up the reddit app on our servers. This is the code running the popular reddit.com website. Here is the app running on a WebFaction server:

reddit app on WebFaction

The list of dependencies is a bit daunting and two of the tools (the reddit app itself and Cassandra) assume that you have root access in their installation guides. Let’s follow the reddit installation guide and see how we can work around the lack of root access. There are a lot of steps to install the app but we’ll be rewarded in the end by a fast and nice-looking reddit app instance:

1. Create a “custom app” in the WebFaction control panel

The reddit app runs the Pylons web server so we go to “Domains / websites -> Applications”” in the control panel and create a “Custom application running on port”. Let’s call it “reddit”. All this does is create an empty directory names $HOME/webapps/reddit on the server and give us a port that we can use to run the app on (in this case the port is 17594). When we point a domain to that app the front Nginx server on the server will get configured to proxy all requests to that port.

2. Create a website in the control panel to point a domain to the custom app

In step 1 we created a custom app called “reddit”. The next step is to go to “Domains / websites -> Websites” in the control panel and to create a website. Let’s set it up to serve the “reddit” app at http://demo.webfactional.com.

3. Create a Postgresql database from the control panel and load the reddit SQL functions

The reddit app requires a Postgresql database. To create one we simply go to “Databases” in the control panel and create a new Postgresql database called “demo_reddit”. We take note of the password and then SSH into the server as our normal user (“demo” in this example) to load the reddit SQL functions:

[demo@web356 reddit]$ cd $HOME/webapps/reddit/reddit
[demo@web356 reddit]$ psql -U demo_reddit demo_reddit < sql/functions.sql
Password for user demo_reddit:
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE VIEW
[demo@web356 reddit]$

4. Download the reddit app code and update the config files

[demo@web356 ~]$ cd $HOME/webapps/reddit
[demo@web356 reddit]$ git clone git://github.com/reddit/reddit.git
Cloning into reddit...
remote: Counting objects: 21254, done.
remote: Compressing objects: 100% (4888/4888), done.
remote: Total 21254 (delta 17314), reused 20069 (delta 16305)
Receiving objects: 100% (21254/21254), 14.36 MiB | 3.63 MiB/s, done.
Resolving deltas: 100% (17314/17314), done.
[demo@web356 reddit]$
# Update the config file with our own settings
[demo@web356 ~]$ sed -i 's/reddit.local/demo.webfactional.com/g' $HOME/webapps/reddit/reddit/r2/example.ini
[demo@web356 ~]$ sed -i 's/db_user = reddit/db_user = demo_reddit/' $HOME/webapps/reddit/reddit/r2/example.ini
[demo@web356 ~]$ sed -i 's/db_pass = password/db_pass = secret-password/' $HOME/webapps/reddit/reddit/r2/example.ini
[demo@web356 ~]$ sed -i 's/reddit,   127.0.0.1/demo_reddit,   127.0.0.1/' $HOME/webapps/reddit/reddit/r2/example.ini

5. Setup SunJDK

The reddit app requires Cassandra which runs on Java. All WebFaction servers come with OpenJDK but in our tests Cassandra didn't seem to work with that version of Java. So we're going to install SunJDK in our HOME directory and point our JAVA_HOME environment variable to it:

 <download jdk-7u7-linux-x64.tar.gz from http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html and place the file in $HOME on the server>
[demo@web356 ~]$ cd $HOME
[demo@web356 ~]$ tar xf jdk-7u7-linux-x64.tar.gz
[demo@web356 ~]$ export JAVA_HOME=$HOME/jdk1.7.0_07

6. Setup Cassandra

[demo@web356 ~]$ cd $HOME
[demo@web356 ~]$ wget http://apache.mesi.com.ar/cassandra/1.1.5/
        apache-cassandra-1.1.5-bin.tar.gz
[...]
2012-10-15 15:56:27 (3.97 MB/s) - apache-cassandra-1.1.5-bin.tar.gz
[demo@web356 ~]$ tar xf apache-cassandra-1.1.5-bin.tar.gz
# Tell Cassandra to put its data in $HOME/webapps/reddit/cassandra-data
[demo@web356 ~]$ mkdir $HOME/webapps/reddit/cassandra-data
[demo@web356 ~]$ sed -i 's/\/var\/lib\/cassandra\/data/\/home\/demo\/webapps\/reddit\/cassandra-data/' $HOME/apache-cassandra-1.1.5/conf/cassandra.yaml
[demo@web356 ~]$ sed -i 's/\/var\/lib\/cassandra\/data/\/home\/demo\/webapps\/reddit\/cassandra-data/' $HOME/apache-cassandra-1.1.5/conf/cassandra.yaml
[demo@web356 ~]$ sed -i 's/\/var\/lib\/cassandra\/commitlog/\/home\/demo\/webapps\/reddit\/cassandra-data\/commitlog/' $HOME/apache-cassandra-1.1.5/conf/cassandra.yaml
[demo@web356 ~]$ sed -i 's/\/var\/lib\/cassandra\/saved_caches/\/home\/demo\/webapps\/reddit\/cassandra-data\/saved_caches/' $HOME/apache-cassandra-1.1.5/conf/cassandra.yaml
# Start Cassandra
[demo@web356 ~]$ cd $HOME/apache-cassandra-1.1.5/bin
[demo@web356 bin]$ ./cassandra
xss =  -ea -javaagent:./../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms3980M -Xmx3980M -Xmn800M -XX:+HeapDumpOnOutOfMemoryError -Xss180k
[...]
 INFO 16:12:00,714 Node localhost/127.0.0.1 state jump to normal
 INFO 16:12:00,714 Bootstrap/Replace/Move completed! Now serving reads.

Cassandra is now running. In a production setup we would have started Cassandra in the background but in this example we started it in the foreground so we'll leave that window open and will run the next commands in a new SSH session in another window:

[demo@web356 ~]$ cd /home/demo/apache-cassandra-1.1.5/bin
[demo@web356 bin]$ ./cassandra-cli -h localhost
Connected to: "Test Cluster" on localhost/9160
Welcome to Cassandra CLI version 1.1.5

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.

[default@unknown] create keyspace reddit;
9a890e19-4fe7-3655-afdb-95bcc7065947
Waiting for schema agreement...
... schemas agree across the cluster
[default@unknown] use reddit;
Authenticated to keyspace: reddit
[default@reddit] create column family permacache with column_type = 'Standard' and comparator = 'BytesType';
5f39dc3d-e8fc-34db-bb59-f3806851300c
Waiting for schema agreement...
... schemas agree across the cluster
[default@reddit]

Note that depending on its configuration Cassandra can use a lot of memory (1GB or more) so you will need enough memory on your account to run it.

7. Install Erlang

The reddit app requires RabbitMQ, which in turn requires Erlang. Since Erlang isn't installed globally on the WebFaction servers we'll just install it in our HOME directory:

[demo@web356 ~]$ cd
[demo@web356 ~]$ wget http://www.erlang.org/download/otp_src_R15B02.tar.gz
[...]
2012-10-16 11:18:19 (430 KB/s) - otp_src_R15B02.tar.gz
[demo@web356 ~]$ tar xf otp_src_R15B02.tar.gz
[demo@web356 ~]$ cd otp_src_R15B02
[demo@web356 otp_src_R15B02]$ mkdir $HOME/erlang
[demo@web356 otp_src_R15B02]$ ./configure --prefix=$HOME/erlang
Ignoring the --cache-file argument since it can cause the system to be erroneously configured
Disabling caching
checking build system type... x86_64-unknown-linux-gnu
[...]
                 Using fakefop to generate placeholder PDF files.

*********************************************************************
[demo@web356 otp_src_R15B02]$ make
cd erts && ERL_TOP=/home/demo/otp_src_R15B02 make NO_START_SCRIPTS=true  FLAVOR=
make[1]: Entering directory `/home/demo/otp_src_R15B02/erts'
[...]
make[2]: Leaving directory `/home/demo/otp_src_R15B02/erts/start_scripts'
make[1]: Leaving directory `/home/demo/otp_src_R15B02/erts'
[demo@web356 otp_src_R15B02]$ make install
[...]
cd erts && ERL_TOP=/home/demo/otp_src_R15B02 make NO_START_SCRIPTS=true  FLAVOR=
make[1]: Entering directory `/home/demo/otp_src_R15B02/erts'
ln -s ../lib/erlang/bin/ct_run ct_run
ln -s ../lib/erlang/bin/run_test run_test
[demo@web356 otp_src_R15B02]$ export PATH=$PATH:$HOME/erlang/bin

8. Setup RabbitMQ

[demo@web356 ~]$ cd
[demo@web356 ~]$ wget http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.7/rabbitmq-server-generic-unix-2.8.7.tar.gz
[...]
2012-10-16 13:41:53 (686 KB/s) - rabbitmq-server-generic-unix-2.8.7.tar.gz
[demo@web356 ~]$ tar xf rabbitmq-server-generic-unix-2.8.7.tar.gz
# Set a few environment variables to tell RabbitMQ to only listen to localhost
[demo@web356 ~]$ export RABBITMQ_NODENAME=rabbit@localhost
[demo@web356 ~]$ export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1
[demo@web356 ~]$ export ERL_EPMD_ADDRESS=127.0.0.1
[demo@web356 ~]$ cd rabbitmq_server-2.8.7/sbin
[demo@web356 sbin]$ ./rabbitmq-server
Activating RabbitMQ plugins ...
[...]
starting notify cluster nodes                                         ...done
broker running

The RabbitMQ server is now running. Again, in a production setup we would have started it in the background but in this example we started it in the foreground so we'll leave that window open and will run the next commands in a new SSH session in another window.
The next step is to add a user in RabbitMQ:

[demo@web356 ~]$ export PATH=$PATH:/home/demo/erlang/bin
[demo@web356 ~]$ export RABBITMQ_NODENAME=rabbit@localhost
[demo@web356 ~]$ export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1
[demo@web356 ~]$ export ERL_EPMD_ADDRESS=127.0.0.1
[demo@web356 ~]$ cd $HOME/rabbitmq_server-2.8.7/sbin
[demo@web356 sbin]$ ./rabbitmqctl add_user reddit reddit
Creating user "reddit" ...
...done.
[demo@web356 sbin]$ ./rabbitmqctl set_permissions -p / reddit ".*" ".*" ".*"
Setting permissions for user "reddit" in vhost "/" ...
...done.
[demo@web356 sbin]$

9. Run memcache

Memcache is already install on all WebFaction server so we just need to start an instance:

[demo@web356 ~]$ memcached

The Memcache server is now running. Since we started it in the foreground we'll leave that window open and will run the next commands in a new SSH session in another window.

10. Install Cython

[demo@web356 ~]$ cd
[demo@web356 ~]$ wget http://cython.org/release/Cython-0.17.1.tar.gz
[...]
2012-10-16 14:13:01 (2.36 MB/s) - Cython-0.17.1.tar.gz
[demo@web356 ~]$ tar xf Cython-0.17.1.tar.gz
[demo@web356 ~]$ cd Cython-0.17.1
[demo@web356 Cython-0.17.1]$ python2.7 setup.py install
Compiling module Cython.Plex.Scanners ...
[...]
Writing /home/demo/lib/python2.7/Cython-0.17.1-py2.7.egg-info
[demo@web356 Cython-0.17.1]$

11. Install PyCaptcha

[demo@web356 ~]$ cd
[demo@web356 ~]$ svn co http://svn.navi.cx/misc/trunk/pycaptcha/
A    pycaptcha/BUGS
[...]
 U   pycaptcha
Checked out revision 12529.
[demo@web356 ~]$ cd pycaptcha/
[demo@web356 pycaptcha]$ python2.7 setup.py install
running install
running build
[...]
Writing /home/demo/lib/python2.7/PyCAPTCHA-0.4-py2.7.egg-info
[demo@web356 pycaptcha]$

12. Install libmemcached-0.53 and pylibmc

The reddit app uses pylibmc which requires libmemcached-0.32 or later. Unfortunately the libmemcached version installed globally on the WebFaction servers is 0.31. So we're going to install a newer version (0.53) in our HOME directory and then build pylibmc against this newer version:

[demo@web356 ~]$ cd
[demo@web356 ~]$ wget https://launchpad.net/libmemcached/1.0/0.53/+download/libmemcached-0.53.tar.gz
[...]
2012-10-16 14:30:12 (322 KB/s) - libmemcached-0.53.tar.gz
[demo@web356 ~]$ tar xf libmemcached-0.53.tar.gz
[demo@web356 ~]$ cd libmemcached-0.53
[demo@web356 libmemcached-0.53]$ mkdir $HOME/libmemcached
[demo@web356 libmemcached-0.53]$ ./configure --prefix=$HOME/libmemcached
[...]
   * Warnings as failure:       no
---
[demo@web356 libmemcached-0.53]$ make install
[...]
make[1]: Leaving directory `/home/demo/libmemcached-0.53'
[demo@web356 libmemcached-0.53]$ export LD_LIBRARY_PATH=$HOME/libmemcached/lib
[demo@web356 libmemcached-0.53]$ cd
[demo@web356 ~]$ wget http://pypi.python.org/packages/source/p/pylibmc/pylibmc-1.2.3.tar.gz
[...]
2012-10-16 14:48:05 (390 KB/s) - pylibmc-1.2.3.tar.gz
[demo@web356 ~]$ tar xf pylibmc-1.2.3.tar.gz
[demo@web356 ~]$ cd pylibmc-1.2.3
[demo@web356 pylibmc-1.2.3]$ python2.7 --with-libmemcached=/home/demo/libmemcached/ setup.py install
running install
[..]
Writing /home/demo/lib/python2.7/pylibmc-1.2.3-py2.7.egg-info
[demo@web356 pylibmc-1.2.3]$ 

13. Install Pylons

[demo@web356 ~]$ cd
[demo@web356 ~]$ wget http://pypi.python.org/packages/source/P/Pylons/Pylons-1.0.1.tar.gz
[...]
2012-10-16 14:06:50 (2.40 MB/s) - Pylons-1.0.1.tar.gz
[demo@web356 ~]$ tar xf Pylons-1.0.1.tar.gz
[demo@web356 ~]$ cd Pylons-1.0.1
[demo@web356 Pylons-1.0.1]$ python2.7 setup.py install
[...]
Installed /home/demo/lib/python2.7/repoze.lru-0.6-py2.7.egg
Finished processing dependencies for Pylons==1.0.1
[demo@web356 Pylons-1.0.1]$

14. Build the reddit app

[demo@web356 ~]$ cd $HOME/webapps/reddit/reddit/r2
[demo@web356 r2]$ sed -i 's/PYTHON=python/PYTHON=python2.7/' Makefile
[demo@web356 r2]$ make pyx
[+] including definitions from Makefile.py
cython r2/lib/utils/_utils.pyx
[...]
gcc -pthread -shared build/temp.linux-x86_64-2.7/r2/lib/c/filters.o -L/usr/local/lib -lpython2.7 -o /home/demo/webapps/reddit/reddit/r2/Cfilters.so
touch build/pyx-buildstamp
[demo@web356 r2]$ python2.7 setup.py develop
[...]
Using /home/demo/lib/python2.7/MarkupSafe-0.15-py2.7-linux-x86_64.egg
Finished processing dependencies for r2==0.0.0dev
[demo@web356 r2]$

15. Start the reddit app

We have now installed all the dependencies and configured the reddit app with our settings. The final step is to start the reddit app on the port that was given to us in step 1:

[demo@web356 ~] cd $HOME/webapps/reddit/reddit/r2
[demo@web356 r2]$ paster serve --reload example.ini http_port=17594
Starting subprocess with file monitor
Overriding g.http_port to 17594
reddit app web356.webfaction.com:11612 started a84ad12 at 2012-10-16 15:00:28.862558
Starting server in PID 11612.
serving on 0.0.0.0:17594 view at http://127.0.0.1:17594

16. Check out our handy work

We point our browser at http://demo.webfactional.com/ and can finally get our reward:
reddit app on WebFaction

17. A bit of fun

We couldn't resist doing some basic load-testing on the app to see what kind of figures we'd get:

[demo@web356 ~]$ ab -n 1000 http://demo.webfactional.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking demo.webfactional.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx
Server Hostname:        demo.webfactional.com
Server Port:            80

Document Path:          /
Document Length:        30282 bytes

Concurrency Level:      1
Time taken for tests:   3.349 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      30607000 bytes
HTML transferred:       30282000 bytes
Requests per second:    298.63 [#/sec] (mean)
Time per request:       3.349 [ms] (mean)
Time per request:       3.349 [ms] (mean, across all concurrent requests)
Transfer rate:          8926.04 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     3    3   1.0      3      35
Waiting:        3    3   1.0      3      34
Total:          3    3   1.0      3      35

Percentage of the requests served within a certain time (ms)
  50%      3
  66%      3
  75%      3
  80%      3
  90%      4
  95%      4
  98%      4
  99%      4
 100%     35 (longest request)
[demo@web356 ~]$

Almost 300 requests per second on a simple shared account and without any tweaking. That's a pretty good figure.

Final notes

The steps to set up an app such as the reddit app on a WebFaction shared server without root access are almost the same as the steps with root access. A few things are slightly harder (having to specify the --prefix=$HOME/tool option when compiling certain tools) but on the other hand you won't have to do all the sysadmin work that our team does: applying security patches to globally installed software, monitoring the server, fixing server issues when they arise etc.

Posted in General | 7 Comments

Video and image processing on WebFaction servers

There’s a common misconception that you can’t use shared hosting for interesting tasks like image and video processing. But at WebFaction we say au contraire; today we’re taking a look at the image processing tools available on our servers.

For starters, let’s take ImageMagick for test drive. ImageMagick is a library and collection of command line tools for working with bitmap images. Here it is on web310:

$ convert -version
Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

ImageMagick has a broad range of capabilities, from resizing an image to creating animations. Here’s an example of converting the WebFaction logo from one type to another:

$ convert -quality 50 webfaction-logo.png webfaction-logo.jpg

ImageMagick is handy to have around, but if you’re working with Python, you might prefer to use PIL, the Python Imaging Library. Like ImageMagick, PIL provides a variety of ways to manipulate images. Here’s an example of resizing an image with PIL (on web310):

$ python2.7
Python 2.7.3 (default, May 18 2012, 14:51:16)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> im = Image.open("webfaction-logo.png")
>>> small = im.resize((130, 30))
>>> small.save("webfaction-logo-small.png")

Still images are nice, but it doesn’t hurt to add some motion and sound every now and then. FFmpeg provides a number of tools and libraries for working with video and audio. Here’s an example of converting a Quicktime video from a point-and-shoot camera to a web-friendly MP4:

$ ffmpeg -v 0 -i short_clip.mov short_clip.mp4
FFmpeg version UNKNOWN, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-libamr-nb --enable-libamr-wb --enable-   libfaac --enable-libfaad --enable-libmp3lame --enable-nonfree
  libavutil     49.14. 0 / 49.14. 0
  libavcodec    52.15. 0 / 52.15. 0
  libavformat   52.28. 0 / 52.28. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Sep 13 2011 08:22:01, gcc: 4.4.4 20100726 (Red Hat 4.4.4-13)
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=  224 fps= 50 q=31.0 Lsize=    1301kB time=7.38 bitrate=1443.7kbits/s
video:1239kB audio:57kB global headers:0kB muxing overhead 0.414617%

And, as we’ve mentioned previously, you can build other great image and video tools in your home directory. What are you doing with images and video? Let us know in the comments. If you have any questions, join us on the Q&A Community.

Posted in General | 7 Comments

A look at other languages available on our servers

Previously, we’ve taken a close look at Python, PHP, and Ruby on WebFaction, which stand out as popular languages with WebFaction users. But there’s a long tail of other languages available and in use on WebFaction servers.

For example, the venerable Perl programming language is available on all WebFaction servers. But not just Perl alone: you also have access to CPAN, the Comprehensive Perl Archive Network, to install a huge variety of libraries. Check out our CPAN documentation for detailed steps to installing modules with CPAN.

Likewise, Java is available on WebFaction servers with OpenJDK. Here’s Web310:

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (rhel-1.50.1.11.5.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

And though PHP, Python, Ruby, Perl, and Java are some of the most common tools, they’re not comprehensive and we haven’t thought of everything. But WebFaction servers come with tools to make it possible for you to bring in your own toolchest. For example, GCC, a C/C++ compiler, and make are installed on all WebFaction servers, so you can build other software yourself.

Suppose you want to use Erlang, a language known for its support for concurrency. Erlang is not installed by default, but with the help of make and gcc (among several others), you can install in your home directory. Here’s a demonstration of downloading, building, and running an Erlang program on Web310 (long boring parts omitted):

$ wget http://www.erlang.org/download/otp_src_R15B02.tar.gz
$ tar -xf otp_src_R15B02.tar.gz
$ cd otp_src_R15B02
$ ./configure --prefix=$HOME
$ make
$ make install
$ cat > hello.erl << EOF
> -module(hello).
> -export([hello_world/0]).
>
> hello_world() -> io:fwrite("Hello, WebFactioneers!\n").
> EOF
$ erl
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:16:16] [async-threads:0] [hipe]   [kernel-poll:false]

Eshell V5.9.2  (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:hello_world().
Hello, WebFactioneers!
ok
3>

Hopefully, this gives you a glimpse of the possibilities open to your WebFaction account, even if they’re off the beaten path. Let us know what you’re using in the comments. If you have any questions, join us on the Q&A Community.

Posted in General | 10 Comments