-
Notifications
You must be signed in to change notification settings - Fork 20
How develop and deploy an application in the cloud. A referencial architecture (Part 1).
I want to share my experience developing an application in the cloud. Today the cloud is an atractive option for developers, we don't need worry for low level details of the infraestructure.
This architecture shown us how develop our applications using services available in Internet.
I use Openshift to deploy a Django application and Redis in the Cloud for caching the site.
See the follow diagram.
We deploy a site on Openshift using Django 1.6 Framework with the Python 2.7 runtime. To assure the performance of our site we going to use Redis.IO to cache the site.
Openshift (https://www.openshift.com) is our PaaS (Platform as a Service) with the runtime Python, Django and packages to connect Django with Redis (django-redis-cache and hiredis).
In Django's settings.py file, we set the values to connect Django with Redis.
# If you want configure the REDISCLOUD
if 'REDISCLOUD_URL' in os.environ and 'REDISCLOUD_PORT' in os.environ and
'REDISCLOUD_PASSWORD' in os.environ:
redis_server = os.environ['REDISCLOUD_URL']
redis_port = os.environ['REDISCLOUD_PORT']
redis_password = os.environ['REDISCLOUD_PASSWORD']
CACHES = {
'default' : {
'BACKEND' : 'redis_cache.RedisCache',
'LOCATION' : '%s:%d'%(redis_server,int(redis_port)),
'OPTIONS' : {
'DB':0,
'PARSER_CLASS' : 'redis.connection.HiredisParser',
'PASSWORD' : redis_password,
}
}
}
MIDDLEWARE_CLASSES = ('django.middleware.cache.UpdateCacheMiddleware',) +
MIDDLEWARE_CLASSES +
('django.middleware.cache.FetchFromCacheMiddleware',)
For our example, we need to set the environment variables REDISCLOUD_URL, REDISCLOUD_PORT and REDISCLOUD_PASSWORD for our application deployed in Openshift. See for details in this link: https://github.com/rancavil/django-py3-openshift-quickstart/wiki/Django-1.6-with-Redis-Cloud.
Redis – Cloud is Redis.IO in the cloud (http://redislabs.com/), we need create us an account and create a database to get the endpoint information for the REDSCLOUD_URL and REDISCLOUD_PORT environment variables. When you create the database in RedisLabs, you put the password, you must remember, or see later in the admin web console, to config REDISCLOUD_PASSWORD.
You can see the endpoint information in the Manage Resources in the admin web console of Redislabs.
Again, REDISCLOUD_URL and REDISCLOUD_PORT represents the address and port where Django locates Redis, RedisLabs in this case. When we created the resource (Redis DB) in RedisLabs (formely redis – cloud) we put a password, this is REDISCLOUD_PASSWORD.
If you want to see more details how create and deploy Django with Redis – Cloud on Openshift, check https://github.com/rancavil/django-py3-openshift-quickstart/wiki/Django-1.6-with-Redis-Cloud.
Well, now I want to share some aspect I consider important to keep in mind when we use the cloud to deploy our applications.
Advantages:
When we use an PaaS and his services in the cloud, there are a lot of advantages to consider.
- We don't need worry for the low level details of the infraestructura.
- We can focus in our application and his functionality.
- We have flexibility in the use of the resources.
- We pay only for what we use.
On other hand, we need to consider some issues when we use of services in the cloud. Remember, we are distributing our functionalities in the web.
- We must trust in the Service Level Agreements (SLA).
- We must trust in our providers.
- We need take all technical cautions to assure the application uptime.
- Consider the performance needs.
Finally, today we can trust in the cloud and develop good applications.