Deploying strategies for small websites

Programming January 28th, 2012

Most one person startups do not have enough infrastructure to deploy on a distributed failsafe website. I was just looking at shared hosting options like Godaddy, Dreammhost, Bluehost and webfaction among others. I was curious about the memory limits offered at each hosting and was too lazy to read their pricing pages for the information. What was easy was to write a short script in python that would just hog some memory and see when my process is taken down by the host.

My script:


a = []
>>> def memory_hog():
... for i in range(1000):
... a.append(a + ["what"])
>>> memory_hog()
>>> memory_hog()
.
x times
.
>>> memory_hog()

Dreamhost was pretty prompt in killing my python processes as soon as the python process hit 512MB of RAM with the following message.

“Yikes! One of your processes (python, pid 22279) was just killed for excessive resource usage.
Please contact DreamHost Support for details.”

It was depressing that Godaddy hosting services only offered python 2.4 but it does not matter for this test. On the specific Godaddy server that I was testing, there was a total of 12G of memory and I was able to easily hog memory for well over 2G and my process was not killed. I did not test my limit to see if the server goes down since python 2.4 was already not worth for me to explore more.

Webfaction claims to have a memory limit of 256MB which is quite constrained.

My hope is to use a combination of AWS and a few of these other shared hosting to deploy the site. Maintaining db server, memcache and lb on aws and deploying multiple webservers on shared hosting seems like a possibility.

Storm WordCountTopology Error: Cannot run program “python”

Programming January 22nd, 2012

I have been playing around with Storm which was opensourced by Twitter recently.(Checkout the github code). It is dubbed as a realtime map reduce system but it is very generic to perform a variety of operations.

I explored Storm-Starter which has some examples storm topologies to help get your feet wet. Most java examples worked fine for me but I got issues in running the WordCountTopology. The WordCountTopology example uses the python language to write its bolt. I kept getting the error below:

Cannot run program “python” (in directory “/tmp/cf2bf9a …

The problem was solved by adding the “multilang” directory in Storm-Starter project to the class path.

Removing HTML tags

Programming January 16th, 2012

The code snippet below is a function in python for removing html tags from a text. It can be used from a python terminal as shown in the image or within a python module.

Usage:

1) Remove ‘a’ tags: Type the commands as shown in the image below in a python terminal

Removing HTML tags

OSQA 1.0rc on Django 1.3

Programming November 25th, 2011

OSQA is a stack overflow clone in Django. It is pretty well featured and easy to use compared to a number of other counterparts. Though the next release is waiting for even, there are release candidates and the development version on trunk. If you are planning to use the 1.0 release candidate along with Django 1.3, there are few things that you might likely need to get it working. The primary changes are related to modules being moved around on Django 1.3.

In settings.p, you will require the following changes.

TEMPLATE_LOADERS = [
-'django.template.loaders.filesystem.Loader',
-'django.template.loaders.app_directories.Loader',
+'django.template.loaders.filesystem.Loader',
+'django.template.loaders.app_directories.Loader',
'forum.modules.template_loader.module_templates_loader',
'forum.skins.load_template_source',
]
TEMPLATE_CONTEXT_PROCESSORS = [
'django.core.context_processors.request',
'forum.context.application_settings',
'forum.user_messages.context_processors.user_messages',
-'django.core.context_processors.auth',
+'django.contrib.auth.context_processors.auth',
]