简体   繁体   English

在aws上运行django项目的最佳方法是什么?

[英]What is the best way to run a django project on aws?

How should the project be deployed and run. 如何部署和运行项目。 There are loads of tools in this space. 这个空间里有很多工具。 Which should be used and why? 应该使用哪个以及为什么?

  • Supervisor
  • Gunocorn Gunocorn
  • Ngnix Ngnix
  • Fabric
  • Boto 宝途
  • Pip 果仁
  • Virtualenv VIRTUALENV
  • Load balancers 负载平衡器

It depends on your configuration. 这取决于您的配置。 We are using the following stack for our environment on Rackspace, but you can setup the same thing on AWS with EC2 instances. 我们在Rackspace上使用以下堆栈作为我们的环境,但您可以在AWS上使用EC2实例设置相同的内容。

  • Ubuntu 11.04 Ubuntu 11.04
  • Varnish (in memory cache) to avoid disk seeks 清漆(在内存缓存中)以避免磁盘搜索
  • NginX to server static content NginX到服务器的静态内容
  • Apache to server dynamic content (MOD-WSGI) Apache到服务器的动态内容(MOD-WSGI)
  • Python 2.7.2 with Django 使用Django的Python 2.7.2
  • Jenkins for our continuous builds Jenkins为我们的持续构建
  • GIT for version control GIT用于版本控制
  • Fabric for the deployment. 用于部署的Fabric。

So the way it works is that a GIT push to the origin repository is being polled by Jenkins. 因此它的工作方式是Jenkins正在调查GIT对原始存储库的推送。 Jenkins then pulls the changes down from the origin. 詹金斯然后从原点拉下变化。 Builds a Python Egg, runs Unit tests, uses Fabric to deploy this egg to the environments necessary and reloads the Apache config to make sure the forked Apache processes are picking up the new Python egg. 构建一个Python Egg,运行Unit测试,使用Fabric将这个egg部署到必要的环境中并重新加载Apache配置,以确保分叉的Apache进程正在获取新的Python egg。

Hope this helps. 希望这可以帮助。

As Michael Klockel already stated depends on your configuration, I have: 正如Michael Klockel已经说明取决于您的配置,我有:

  • Ubuntu 10.04 LTS Ubuntu 10.04 LTS
  • Nginx Nginx的
  • Uwsgi Uwsgi
  • git version control git版本控制
  • python virtualenv and pip python virtualenv和pip

You can check the deployment settings here: Django, Virtualenv, nginx + uwsgi import module wsgi error 您可以在此处检查部署设置: Django,Virtualenv,nginx + uwsgi导入模块wsgi错误

and why I use nginx and uwsgi here: http://nichol.as/benchmark-of-python-web-servers 为什么我在这里使用nginx和uwsgi: http//nichol.as/benchmark-of-python-web-servers

Also I use fabric for the deployment of the app, and chef solo http://ericholscher.com/blog/2010/nov/8/building-django-app-server-chef/ 此外,我使用面料部署应用程序,厨师独奏http://ericholscher.com/blog/2010/nov/8/building-django-app-server-chef/

johny cache for sql queries and raven and sentry to keep a log of whats going on on the app. johny缓存sql查询和raven和sentry来记录应用程序上的最新情况。

I'd use uWSGI+Nginx from a performance perspective (I think the comparison has already been linked in another answer), pip and virtualenv for deployment as this keeps things self-contained, and facilitates clean deployment using fabric or similar. 我从性能角度使用uWSGI + Nginx (我认为比较已经在另一个答案中进行了链接),pip和virtualenv用于部署,因为这样可以保持自包含,并使用结构或类似方式促进清洁部署。 Use git for version control. 使用git进行版本控制。 Jenkins can handle continuous integration. Jenkins可以处理持续集成。 I'd use the AWS load balancer (ELB) in front of your EC2 instances for balancing - does the job without you having to fret too much about it. 我会在您的EC2实例前面使用AWS负载均衡器(ELB)进行平衡 - 完成这项工作时无需担心太多。 django-storages for uploading your static files to s3, that saves you the effort of having another server to hand out static files. 用于将静态文件上传到s3的django-storage ,可以节省您使用另一台服务器分发静态文件的工作量。

However, it depends a little on your admin overheads. 但是,它取决于您的管理开销。 If you're looking for something clean and simple for deployment and scaling, I'd scrap the whole AWS EC2 stack, use Heroku as a front end, and s3 for your static files. 如果您正在寻找干净且易于部署和扩展的东西,我会废弃整个AWS EC2堆栈,使用Heroku作为前端,使用s3作为静态文件。 This saves all the admin time of maintaining the boxes, and allows you to concentrate on the dev. 这节省了维护盒子的所有管理时间,并使您可以专注于开发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM