服务器软件的选择。Django的直播/舞台 [英] Server software choice for Django live/staging

查看:278
本文介绍了服务器软件的选择。Django的直播/舞台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关发展我们的Django的web应用程序,我想搬到一个自治系统自动更新的具有几乎相同的性能,应用程序的现场版应用程序的分段复制源(从VCS)。这样做的总体思路已经在这里覆盖在SO <一个href=\"http://stackoverflow.com/questions/625256/how-do-i-run-one-version-of-a-web-app-while-developing-the-next-version\">#625256. Django文档还谈到<一个href=\"http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#multiple-django-installations-on-the-same-apache\"相对=nofollow>设置虚拟主机以主机上的同一个Apache Django的2个实例。很多件,我需要的地方设置此已

我什么特​​别的问题 - 我应该选择什么样的服务器软件,如果安装程序将在Windows Server上运行2000

阿帕奇+ MOD-WSGI似乎是自然的选择,但根据的这个博客帖子通过在Apache格雷厄姆邓普尔顿MOG-WSGI运行在Windows上无法加载它的各个过程,需要重新启动整个Apache服务。这是一个的不走的,因为我不希望现场直播辍学每当我们更新升级的code执行。

什么是服务器软件的最佳选择,这种情况?


  1. 维护的Apache 2份可独立重启的(这种感觉坏)的?

  2. 迁移Apache以外的其他东西吗?

  3. ???


解决方案

使用Apache时,有在Windows上没有'单个进程',只存在一个Apache的工作进程。此外,有Windows上的守护进程模式两种。无论如何,这一切意味着什么是这两个Django的情况下,不要在一个进程中运行,尽管在不同的子间preters。所以,是的,造成code一个Django的网站重新加载将对他们,因为在同一个进程被其他网站的影响。

如果一个是在UNIX系统上,可以发送一个kill信号给工人/守护进程,他们将重新启动,而不重新启动整个的Apache。在UNIX上,这并不过分导致该重启过程中到达,即使在同一个进程上的HTTP请求被接受端口监听套接字多个站点保持全天开放的问题,因此后续的请求只是排队,将被一次处理工人/守护进程重新运行。

在Windows作为你正确地拿起整个阿帕奇必须重新启动。这意味着,永远这么小的时间监听套接字将被关闭掉,并会出现一个小窗口,请求将得到一个连接失败。这是一个窗口多久你真的需要做一些测试。通常它是不是一个巨大的问题,因为是足够短,低概率的要求将达到那个precise时刻。换句话说,你可能会过于令人担忧的,如果你只谈论给出一个临时的环境,不希望过于频繁地重新启动。如果你试图运行在同一个Apache实例的开发网站,那么这将是一个问题。

这一切说,如果你想要分期实例是尽可能接近生产,然后将仍然需要运行Apache等不同端口的多个实例的Apache将是唯一合乎逻辑的解决方案。你可以在CherryPy的WSGI服务器或粘贴WSGI服务器和代理它之上运行Django的,但它是一个不同的主机系统,将不同的行为对您可能不接这将最终在发生生产安装问题的程度。

所有的时候,我会建议你做一些实际的测试,在运行的Apache对基准和在同一时间进行重启,看看有多少的请求,结果失败。这将帮助你了解是否是大问题,你认为它是。

For developing our Django web app, I'd like to move to an autonomous system that automatically updates the source (from VCS) of a staging copy of the app which has near identical properties to the live version of the application. The general idea of doing this has already been covered here on SO #625256. The Django documentation also talks about setting up virtual hosts to host 2 instances of Django on the same Apache. Many of the pieces I need to set this up are already in place.

What my question specifically -- What server software should I choose if this setup will be running under Windows Server 2000?

Apache+mod-wsgi seems like the natural choice, but according to this blog post by Graham Dumpleton mog-wsgi on Apache running on Windows can't reload it's individual process and needs to restart the whole Apache service. This is a no-go as I don't want the live site dropping out whenever we update the staging's code.

What is the best choice of server software for this situation?

  1. Maintain 2 copies of Apache which can be independently restarted (this feels bad)?
  2. Migrate to something other than Apache?
  3. ???

解决方案

There are no 'individual processes' on Windows when using Apache, there is only one Apache worker process. Also, there is no daemon mode on Windows either. Anyway, what it all means is that both Django instances do run in the one process, albeit in different sub interpreters. So yes, to cause code for one Django site to be reloaded will have impacts on the other site because of them being in the same process.

If one was on a UNIX system one could send a kill signal to the worker/daemon processes and they would restart without restart whole of Apache. On UNIX this does not overly cause problems even when multiple sites in same process as the listener socket for port on which HTTP requests are accepted is maintained open at all times, so subsequent requests which arrive during the restart just queue up and will be handled once worker/daemon processes are running again.

On Windows as you rightly pick up the whole of Apache has to be restarted. This means that for ever so small a time that listener socket will be closed off and there will be a small window where requests will get a connection failed. How long a window this is you will really need to do some testing on. Usually it isn't a huge problem as is short enough that low probability that request will hit at that precise moment. In other words, you may be unduly worrying if you are only talking about a staging environment given that wouldn't expect to restart very often. If you were trying to run a development site on same Apache instance then that would be a problem.

That all said, if you want the staging instance to be as close as possible to production then would still need to be running Apache so multiple Apache instances on different ports would be only logical solution. You could run Django on top of CherryPy WSGI server or Paste WSGI server and proxy to it, but then it is a different hosting system and will behave differently to the extent that you may not pick up issues which would ultimately occur when on production setup.

All up, I would suggest you actually do some tests where you run benchmarks against Apache and perform a restart at same time and see how many requests fail as a result. This will help you understanding whether it is the big problem you think it is.

这篇关于服务器软件的选择。Django的直播/舞台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆