24 jun

CloudVPS – PW Webdevelopment Case Study: Object Store S3 emulation for Django

PW Webdevelopement's first project with the CloudVPS Object Store was a web application for the distribution and modification of price cards for airport shops in different international airports. PW Webdevelopment has been using an object store to store media files of their applications for a couple of years now.

Peter Wiggers, founder of PW Webdevelopment: “The biggest advantages of using an object store for the meda files are scalability and the high level of built-in redundancy. The extra security compared to maintaining a separate file server also plays its part.”.

The media files related to this application were placed on Amazon S3 in the past. PW Webdevelopment recently decided to move their data to the CloudVPS Object Store, however.

Peter Wiggers: “Our customers have reported that the fact that the data is stored in the Netherlands is a big advantage. In the first place they have experienced a significant improvement in performance. Secondly, the larger degree of privacy protection is also perceived as very important.”.

The Application

Within the application pre-designed price cards are stored in the object store. These can be downloaded, adapted and printed by a large number of airport shops. The price cards are subsequently placed on shelves and display furniture.

The application is written in Python and uses the Django framework. The Django module that takes care of the connection with the object store is django-storages, which supports the S3 API. Because the CloudVPS Object Store emulates the S3 API, almost no code had to be adjusted.

Implementation CloudVPS Object Store S3 Emulation

The below instructions assume that a CloudVPS Object Store is available and that a container has been created in the account. We also asume that a S3-token has been generated in the CloudVPS Interface.

In order to integrate the CloudVPS Object Store in an existing Django web application, the following packages are required:

  • boto
  • python-dateutil (noodzakelijk voor collectstatic)
  • django-storages

The first two can be installed from PyPl's repositories, but this is not recommended for django-storages. In the version on PyPl the possibility to configure a custom host is not yet possible. Use Bitbucket to install the latest version:

pip install -e hg+https://bitbucket.org/david/django-storages#egg=storages

And add 'storages' to the INSTALLED_APPS tuple in the Django settings.

A large advantage of the CloudVPS Object Store is that it is largely S3 compatible. That is why the built in S3 libraries of boto and django-storages can be used and why it is easy to connect existing apps to the object store. Open the setting.py (or similar) and add the configuration below:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = '{input_objectstore_access_token}'
AWS_SECRET_ACCESS_KEY = '{input_objectstore_secret}'
AWS_STORAGE_BUCKET_NAME = '{input_objectstore_containernaam}'
AWS_S3_HOST = '{input_objectstore_id}.objectstore.eu'
AWS_S3_CUSTOM_DOMAIN = "%s/%s" % (AWS_S3_HOST, AWS_STORAGE_BUCKET_NAME)

All variables between brackets can be found in the CloudVPS Interface under object store > S3 API Tokens.

That's it! Your Django app now works with the CloudVPS Object Store!

In case you want to use the Swift backend for new Django apps: this has not yet been incorporated in django-storages. There is a fork of this package available that does support the Swift API however.


OpenStack and CloudVPS Object Store

CloudVPS aims to offer the best possibilities of the cloud to its customers. That is why we have decided to implement OpenStack across our entire infrastructure. OpenStack is a fast expanding collection of open source cloud infrastructure components that is supported by important players like HP, NASA and VMware. The use of OpenStack will yield our customers a lot of new functionality as well as a popular API that can be used to communicate with our infrastructure.

The first OpenStack-based product has already been launched: In april 2013 we launched the first object store in the Netherlands. The CloudVPS Object Store is a cheap, open and privacy-conscious alternative to first generation services like Amazon S3.

An object store is a modern way to serve files for an application or website. With an object store files can be stored, managed and requested in the cloud by easy API-calls or a URL. The technology is extremely suitable for larger files like images and other media types. Data is stored three times on three different machines in at least two different datacenters.

When you use an object store you only pay for the actual usage. This usage consists of the following elements: storage, outgoing traffic, heavy requests (like writes) and light requests (like reads). On our site you can find more information about the CloudVPS Object Store.

PW Webdevelopment

PW Webdevelopement is a young, dynamic company that develops web applications in order to help companies work more efficiently and more innovatively. The company exclusively works with motivated Master of Science (MSc.) students of the renowned University of Technology Delft. With 150 completed projects PW Webdevelopment is a reliable partner for every digital improvement. PW Webdevelopment is a one stop shop for its customers: From the first brainstorm session to the eventual maintenance and hosting of the custom-built web application.

www.pw-webdevelopment.nl (Dutch)

CloudVPS

CloudVPS is one of the top cloud providers in the Netherlands. From a network that is spread out over three tier-one datacenters they provide services to a large number of well-known and demanding customers. CloudVPS has a large public cloud that can be used to acquire flexible capacity. A lot of private cloud and custom solution experience is available as well.

By combining their own software with existing solutions CloudVPS is able to offer High Availability solutions at an attractive price level. CloudVPS has an international orientation and has a prominent position in the areas of cloud certification and cloud-related open source projects.

www.cloudvps.com