Getting started with Django on Amazon Web Services [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm starting to migrate a few applications to Amazon Web Services. My applications are Python/Django apps, running over MySQL.
I plan on using EC2 and EBS for starters.
I'm looking for a few things:
A good step-by-step tutorial explaining how to deploy Django on AWS. I've looked around, but most tutorials are from 2 years ago, so I'm worried they're outdated.
I'm trying to understand, with which AMI should I start? I know there's a BitNami AMI that comes preconfigured with Django goodiness, but I've seen a lot of other sources say you should start with a basic (clean) linux box and install everything yourself. Why?
Are there any other important things I should be thinking about? I have very little sysadmining experience (the apps are currently on WebFaction), so I'm not sure what I should be thinking about.
A few extra points:
I plan on running several applications on the same EC2 instance, I assume that's possible?
I'm using virtualenv to separate between the various apps right now, I assume I can continue doing the same on the EC2 instance?
Thanks!

There is nothing "special" with EC2 here. It just provides bare (or generally preconfigured from custom AMI) system instance - you have access to whole virtualized system, so you can safely break things on your own. Think about it as a specific VPS.
You have to prepare deployment by yourself, which is not so difficult - just follow the documentation. I'd advice to run with basic linux distro and add needed stuff than to rely on some preconfigured image. As for you questions:
You need to do two things: setup your instance (accounts, needed software, other custom setup, so some linux administration guide should be handy) and prepare django app deployment (deploy python code, hook up to web server). For the latter, general deployment instructions for django can be applied here ( http://docs.djangoproject.com/en/dev/howto/deployment/ ).
Start with AMI with your favorite linux distro, and then add necessary software from it's repository.
Mount and use EBS as soon as possible for all your data. When rebooted, EC2 instance will wipe out all it's data, so be prepared for this. Do system snapshots to AMI to have quick recovery on failure.
Yes, you can deploy several applications on one instance, but mind that EC2 instance is virtualized (with quite high "virtualization tax" imo, especially for smaller instances), so you might run into general performance problems. Assume that you'd need migrate to bigger instance/multiple instances after some time.
Virtualenv should be your default deployment tool. Yes, you can use it here too.

You can follow the official documentation of setting up Amazon ec2 instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html
You should start with an AMI that you are familiar with. For example, if you use Ubuntu, you can just use one of the Ubuntu AMI in the recommended page. I didn't use the BitNami server and my Django site is deployed smoothly.
If you are using Apache server, just follow the instructions on the official Django doc:
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/
I tried quite a few blogs but as you said, they are outdated. Just use the official docs and it will save you a lot of time.

This repo is meant to address exactly this issue - provide a reference implementation for a basic django project that can be deployed onto AWS ElasticBeanstalk.
https://github.com/pushkarparanjpe/django-awsome
It has:
Static assets
DB back-end
django contrib Admin
Just configure your EBS env, clone the repo and deploy!

Related

task runner/queue/scheduling on openshift with django

few days ago I have asked how to send email with django and openshift, but I guess it was too broad since it was closed.
So in this question I would like to know what task runner/queue/scheduling system should I use in general for django and openshift. Unfortunately I have not seen any tutorial for django and openshift.
Looks like celery is too complex to install easily on openshift.
Here are few tasks django-packages.
And openshift also provides IronWorker as scheduling app in marketplace. I tried to add free edition to my app, but I struggle setting it up.
So my question is, what queue system should I use with django and openshift? What do you use on openshift? Currently I only need to send personalised weekly emails, but my app works with few api providers and relatively large data, so I might use it more in the future.
There is no iron/openshift guide for Python, but there is one in Ruby that should give you a general concept- https://github.com/iron-io/ironmq-openshift-quickstart
You can also read our blogpost about the topic- http://www.iron.io/blog/2013/02/ironio-openshift-paas-20-for-enterprise.html

Getting started with Django, Heroku and Amazon

I want to change my static website (http://ingledow.co.uk) to a Django site on Heroku and Amazon using GitHub to store the code.
I've been through the Django tutorial once, so I'm fairly new to the whole thing.
Where would you guys start with this? Any useful books, code learning websites you could recommend to get started?
Thanks
David
To easily understand and visualize Heroku when hosting Django apps I created this drawing for our startup ChattyHive. I hope it is helpful. Don't hesitate on asking me any doubt or suggest anything :)
(please right clic on it and "view picture" to see it full size or it will be too small!)
The best way to learn Python and Django is to be comfortable with creating a proper environment for developing your application, although you can skip the details and start with Heroku's official guide on how to manage a Django application across the whole stack.
At the time of writing, these are some of the essential tools Python developers should be comfortable with:
virtualenv for creating distinct copies of the Python interpreter and it's environment
pip for managing Python dependencies
fabric for defining administrative tasks across all your target environments
puppet or chef for provisioning environments
vagrant for provisioning development environments
I would suggest that you immediately familiarize yourself with vagrant and focus on the virtualenv+pip+fabric trio--these are ubiquitously utilized in any Python web project and your bound to be forced to come to terms with them sooner or later, so get straight to it and you'll be otherwise amazed how you ever managed any Python development without them.
As far as learning Django is concerned, you will need to understand that Django is still just plain-old Python, what WSGI applications are, how domain objects are modeled, how Django routes requests, how views handle requests and how they produce responses, including additional and intermediary framework components. Afterwards, you should be knowledgeable enough to start tackling any requirements you might have of your application.
I will stress that having a good grasp on Python goes a long way in helping you understand how Django was designed and how to better write and organize your application's sources. The documentation is pretty exhaustive and it's the primary resource for any developer, but if you find yourself in need, there are several good books written that focus on providing additional material on certain aspects, but never forget to hone your Python skills.
Worth mentioning is the Django Package index which tracks any Python package specifically written to be integrated with Django. Their repositories are publicly accessible either on Github or Bitbucket and they range from tiny to huge and are an invaluable resource to see how other developers are doing Django development right.
Maybe you should start with some introduction books about Django,like The Django Book.

Hosting my Django site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Hi I'm looking for some advice I currently own a resseller package with Heart internet as I host a few personal websites. However I'm currently learning Django (The python Framework) and want to be able to host my own server.
I have been setting up virtual servers to play around with. Anyway to have SSH access you have to send in and ask them to open it for you, in the meantime of asking them if it was possible to install Django / set up SSH access i was advised that i can't use Django unless i purchase a Virtual machine even though Python is intalled on the server.
Surley i can install Django onto my server if i have SSH access? Has anyone else has a similair issue? Or can anyone advise me on what to do.. The last thing i was to do is spend more money with them.
Thanks.
It sounds like you're describing a shared hosting situation where you have SSH access but the webserver is preconfigured for you. You cannot practically install and serve Django on that machine, because you will not have access to the Apache or other webserver configuration. You could theoretically serve Django from a port other than the typical HTTP port, but this would be extremely irregular and your hosting company would not appreciate it.
You can deploy Django on Heroku: https://devcenter.heroku.com/articles/django . It is free to deploy for extremely low-volume applications or for development; cost scales linearly with capacity above that.
You can also use Google App Engine with a slightly older version of Django. Either of these options have official support from the respective vendors and so they are much better ideas than trying to work around a restriction set by your hosting provider.
Finally, you could pay for a virtual machine, in which you would have full access to the webserver configuration and could serve anything you like. Virtual machines are available from any number of companies at a wide range of price points. You could also develop a Django application without hosting it anywhere but your local machine for starters, and worry about hosting after your application is functional.
AWS :
Free tier available
great support(but for technical help you got to pay)
can use platform (PAAS) BeanStalk
can customize architecture in case you get a dedicated instance
great community of support
Custom domain
great documentation
can SSH
Most popular
Heroku:(Django)
Free to some extent
Can use only POSTgresql in free plan
git must
Good support
easy to start
custom domain
Can use bash in production(Not SSH).. cannot make direct changes in production. This is what makes your App stable. Any change/update goes through git.
code maintenance - good (deployment through git heroku commands only)
use AWS S3 to store static files
Temporary files are removed perodically
Once you scale that they start to bill, it is really costly.
Since this is a PAAS, you have got what you have got. It takes lots of efforts to customize(to some extent) the architecture of the APP.
Google App Engine:( Flask/Django project.)
Free to some extent
very easy to start(hello world app)
custom domain
code maintenance - good (automatic deployment)
Support is not available
Pythonanywhere:
Free to some extent
No custom domain in free plan
easy to use
Good support
Webfaction:(Django)
Not free.. (I think (minimal plan) costs 10 $ per month on shared hosting. )
SSH available
custom domain
Architecture customization.
Good support
I have really good experiences with pythonanywhere.com. It's also free for really small projects.
For me it seems to be just perfect for experimenting with django. Here is a short story how I switched from Google App Engine to pythonanywhere.com: Django unchained - python in the cloud
I was doing the virtual server thing for a while - then entered Heroku. An extremely easy (and in some cases completely free) way to deploy my django application.
I started where you are,in a shared hosting environment trying to make django work. I then taught myself a lot of server admin and server setup things - thereby moving to a dedicated virtual server setup.
Alas making Django work with apache and on a Centos box can be a pain - But Heroku made it all better. Easy app deployment and scalability. Heroku is a cloud application deployment service - it's all the benefits of a virtual server without the setup. It doesn't actually install on your server
Check out these two articles
https://devcenter.heroku.com/articles/django
http://rdegges.com/devops-django-part-4-choosing-heroku (There are some more to this article but they are very lengthy)
I had a new django app up on the internet in half the time. There is lots of cost estimations involved, which is why I would dive deep into the second article and it's various parts.
You can host Django on Amazon EC2. If you take advantage of their free tier you can do so free for one year in a micro instance (618Mb RAM, 30Gb filesystem). You get full control of the machine, including SSH access. There are a number of freely available images that already bundle Django including the BitNami Django Amazon Machine Image which is also available for free (disclaimer: I am one of the BitNami developers)

Deploying Django project on EC2 with BitNami image

I have a complex university project that requires building some specific libraries and the use of threads (AppEngine out of the question), and I want to deploy in on EC2 (Free tier deal).
I was wondering what would be best, to start with a bare linux distribution or the BitNami Django stack ?
I've seen similar questions here, but I'm looking for Pro's and Con's mainly.
The answer is pretty obvious. If you start with the Bitnami stack you'll save yourself the hassle of installing and configuring the various components (web server, gateway, python and the required libs, DB, etc.).
So if you app is pretty straight forward (typical web app) then sure, start with the bitnami stack. At most you'll reconfigure certain parts later on, as needed.
There's no particular joy in installing and configuring it all yourself, imo.

Breaking out of the Google App Engine Python lock-in? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Are there any guidelines to writing Google App Engine Python code that would work without Google's infrastructure on other platforms?
Is there any known attempt to create an open source framework which can run applications designed for Google App Engine on other platforms?
Edit:
To clarify, the question really is:
If I develop an application on Google App Engine now, will I be able to migrate to another platform later, or is it a lock in?
There's a number of components required to make an app fully portable:
The runtime environment itself. This can be ported relatively simply, by setting up a CGI or FastCGI server that emulates the App Engine environment (which itself is basically slightly-enhanced CGI). Most of the code to do this is already in the SDK. Unfortunately, there's no easy pre-packaged toolkit for this yet.
The datastore. By far the most complicated API to port. There are a number of efforts underway: AppScale runs on EC2/Eucalyptus/Xen and uses a HyperTable or HBase backend; it's still very much beta quality and they don't distribute the data connector separately (it's the beginnings of a complete run-your-app-on-your-own-cloud solution). Jens is/was writing an SQLite backend, and there's my own project, BDBDatastore, which uses BDB-JE as the backend, and is fully functional (though beta quality). AppDrop, which others have mentioned, simply uses the development server as a backend, and hence isn't suitable for production use.
The users API needs replacing with something else, such as an OpenID based API. Again, fairly simple, but no premade solutions yet.
The Memcache API needs a backend that uses standard C memcache backends.
The other APIs have perfectly functional backends as part of the SDK, so don't really need porting.
Cron support would also need implementing, as would background processing, XMPP, etc, when they become available.
As you can see, there's a lot of work to be done, but no fundamental barriers to making your App Engine app run outside Google's environment. In fact, if you're interested, you're more than welcome to participate - I and others have plans to combine the solutions for the various pieces into a single 'OpenEngine' solution for hosting your own apps.
Use a high level framework that works on App-Engine. That way you can port your code to other servers when you want.
django has been patched and ported to work in the Appengine patch project and is the most used FW on appengine.
You may want to refer this step by step intro to running a django app on App engine
As far as the parallel infrastructure to run an app engine application is concerned, it is still way far. App Engine itself hasn't got as popular as people believed it to and google wanted it to be. Plus it is harder to develop on the builtin WebApp framework than on django.
Its quite unlikely to see a parallel infrastructure to run app engine application on, atleast for years to come. Rather it is likely to see django and other popular frameworks work out of the box on app engine and the work on this is currently underway in the referred project.
You can build AppEngine applications using the Django python framework (although the supported version is a bit behind the most recent Django release). Where you lose portability (at least right now) is when using GQL/BigTable for persistence. This is Google proprietary database platform. As Hank mentioned this is one of the biggest reasons to actually use AppEngine, but it is also the single largest locking point.
Here are a couple of links to Django support in AppEngine and GQL/BigTable:
http://code.google.com/appengine/articles/django.html
http://code.google.com/appengine/docs/python/datastore/gqlreference.html
So far, I found an experimental host called app-drop which is capable of hosting google app-engine projects. This should mean that it's atleast possible to run app engine projects outside of google's infrastructure.
This is however clearly not yet suitable for production.
The code should be mostly portable (they do a pretty good job of indicating which modules you can't use on AppEngine and which AppEngine-specific code corresponds to which forbidden modules), but the whole point of AppEngine is to get access to Google's infrastructure. There's not much point to writing your code to the AppEngine restrictions if you aren't going to be using their infrastructure.
AppDrop is a proof of concept port of AppEngine to Amazon Web Services / Elastic Computing completed in April of 2008. It uses a flat file instead of BigTable and runs in a single instance, so there are scaling issues; but it's developer says it took him only four days, and perhaps these limitations can be addressed by others.
I did the reverse migration from vanilla Unix to app engine recently very easily by using WHIFF resources. Basically configure anything platform dependant as a resource and then swap/replace the resources on different configurations.
http://piopio.appspot.com/W1000_1000.resources
also see
http://aaron.oirt.rutgers.edu/myapp/docs/W1100_1200.wwiki
for a detailed example of resource swapping/configuration.
(note: links may go away eventually, app is experimental.)
Check out typhoonae. it's in beta, but quite usable – we moved one of our apps to inhouse server running this stack.
AppScale is the most mature open source implementation of Google App Engine. It's been in development since 2008 and currently support all four languages: Python, Java, Go, and PHP. It has users running their application in production today.
The FAQ explains what APIs are supported and what is lacking:
https://github.com/AppScale/appscale/wiki/FAQs
(Disclaimer: I work on the project)

Categories