Live data from Hacker News

Ask HN: Django Deploy Recommendations

news.ycombinator.com

11–20 of 39 posts

Re: Ask HN: Django Deploy Recommendations

#11
http://jacobian.org/writing/django-apps-with-buildout/

Buildout. Like virtualenv but handles downloading correct required package versions too. gives you an isolated shell and django manager in your project directory. You can then distribute your project to different people and servers and ensure the correct version of python, django, etc. is used.

Re: Ask HN: Django Deploy Recommendations

#12

http://www.djangy.com - in private beta, by wednesday we're hoping to invite several hundred more users. if you're in a time crunch, email me (dave@djangy.com) EDIT: email

Having had a quick browse it looks like Heroku for Django, which would be absolutely awesome!

Are you using EC2 behind the scenes, or something else?

You mention database support, but I couldn't see anything about specific vendors. Will there be support for spatial extensions? I'm specifically thinking about Postgres and PostGIS.

Looks like a great project though - I've signed myself up for a beta invite!

Re: Ask HN: Django Deploy Recommendations

#13

http://www.djangy.com - in private beta, by wednesday we're hoping to invite several hundred more users. if you're in a time crunch, email me (dave@djangy.com) EDIT: email

Having had a quick browse it looks like Heroku for Django, which would be absolutely awesome! Are you using EC2 behind the scenes, or something else? You mention database support, but I couldn't see anything about specific vendors. Will there be support for spatial extensions? I'm specifically thinking about Postgres and PostGIS. Looks like a great project though - I've signed myself up for a beta invite!

Thanks, we've been getting GREAT feedback and iterating rapidly.

Yes, we're using EC2 on the backend, and it's distributed and scalable. We currently give each app a MySQL database, but we've been getting a ton of requests for other database support, so it's something we're looking into. Unfortunately there are quite a few other requirements to plow through before we get to that particular feature.

Look for updates this week.

Re: Ask HN: Django Deploy Recommendations

#15
I recommend nginx in front of gunicorn. This way nginx can sit up front and do what it does best: serve static media files and buffer requests and responses.

Set up gunicorn under some kind of process manager. I use daemontools, but runit, upstart, monit, and others can work very well too.

For updating code on the server, I'm a big fan of keeping it simple, and to me that means writing a small shell script that ssh's into your machine and runs the proper commands to update the code and send a HUP signal to gunicorn.

You can even set up this script as a git post-commit hook, so that every time you push, your code is updated. If you have a robust test suite, you can set up a Hudson instance to run this command when all tests pass.

If you plan to have long-lived connections (comet, many requests out to third party services), then make sure you set up gunicorn to use Eventlet workers. What that will do is transform your code into asynchronous evented code using coroutines. But you most likely won't have to worry about that.

Re: Ask HN: Django Deploy Recommendations

#17

http://www.djangy.com - in private beta, by wednesday we're hoping to invite several hundred more users. if you're in a time crunch, email me (dave@djangy.com) EDIT: email

Is this the project that was on HN a while ago asking who was interested?

If I remember correctly people were giving the OP a hard time about using sqlite and not turning off debugging in a live environment. This project looks awesome and I'd really love an invite to the beta.

Re: Ask HN: Django Deploy Recommendations

#18
post #5
post #3

You really should use nginx to serve static files and route everything else to apache. The setup is dead simple.

Know of any tutorials appropriate for a Linux server noob (I'm comfortable with the Linux command line but haven't done much web deployment other than basic one-click xampp stuff)?

It's quite easy. Install nginx, update the config file, generally found in '/etc/nginx/sites-enabled/'

There are plenty of good nginx config examples out there, but to use it as a reverse proxy you want to do something like: location / { proxy_pass http://127.0.0.1:8080/; }

You also need to change your ports.conf file for apache to make it run on a different port if you want nginx running on port 80.

Re: Ask HN: Django Deploy Recommendations

#19
Most of the recommendations here are good. Par for the course in Django deployments and administration is virtualenv, Fabric, pip, and per-server settings files.

On top of those, we use Apache, mod_wsgi, Fabric (in a slightly-weird way which I'll get into below), mod_xsendfile, Mercurial, and a home-grown migration library.

Serving static files via nginx or Apache is fine, but generally requires that you copy them out of your various pluggable apps and into some static docroot on every deploy. We use mod_xsendfile instead (with another Django helper app, which I'm hoping to get onto Bitbucket in the next week or two) to directly serve static assets out of the 'media' directory of each installed Django app.

Our use of Fabric is slightly non-standard, too, as I mentioned; instead of writing a single 'fabfile', we have a collection of development, testing, and deployment commands which use Fabric as a very high-level Python API for distributed command execution.

Regardless of the stack you choose, as a non-sysadmin, there are a few habits and practices I'd strongly recommend you keep in mind to avoid getting yourself into a painful place later:

First, set up a staging environment that looks as much like your production setup as possible. It can be on the same server, or in a local virtual machine, or (even better) on a spare server that can be pressed into duty if the primary ever goes down.

You should always have a recent dump of your production database loaded into this environment, and the ability to pull a more up-to-date snapshot in quickly. (This will help with recovering from major "whoopsies" in production, too, and force you to continually test your backups.)

Second, keep copious, detailed notes on everything you do while deploying, updating, or troubleshooting production issues. I'm literally talking about stuff like this:

  Created uploads directory:
  mkdir /var/www/uploads
  chown www /var/www/uploads
  chmod -x /var/www/uploads

  Configured upload directory in Django settings:
  echo "UPLOAD_FILE_DIRECTORY = /var/www/uploads" >> /usr/local/deploy/myapp/src/myapp/settings.py
Some sysadmins I've worked with literally copy their entire .bash_history file for each session into a running log, though I find that tends to end up with a lot of noise ('cd ..; cd ..; pwd; ls; etc.') that doesn't help when you're trying to triage an issue.

I like to use simple text files (backed up in Dropbox, of course) for these notes, but a wiki is fine if that's your preference. It may seem like pointless duplication of effort at first, but grepping a directory full of notes to see what you changed is a much more reliable triage technique than counting on yourself to remember a bunch of details. This goes double when you're panicking in the middle of a production outage.

Beyond that, everything else is gravy. If you're using Apache/mod_wsgi now, I'd recommend you keep using it until you hit a real scaling limit, or have spare cycles to try out a secondary hosting setup post-launch.

(In case anyone's interested in that migration tool, it's on Bitbucket: https://bitbucket.org/rcoder/finch/overview )

Re: Ask HN: Django Deploy Recommendations

#20
post #5
post #3

You really should use nginx to serve static files and route everything else to apache. The setup is dead simple.

Know of any tutorials appropriate for a Linux server noob (I'm comfortable with the Linux command line but haven't done much web deployment other than basic one-click xampp stuff)?

I love linode's library:

http://library.linode.com/web-servers/nginx/

Post reply on HN