Django的部署:切割Apache的开销 [英] Django Deployment: Cutting Apache's Overhead

查看:197
本文介绍了Django的部署:切割Apache的开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了,可供静态媒体文件,并将Django的请求返回到Apache 2.2 prefork MPM服务器上运行的mod_wsgi Nginx的一个前端的小VPS服务器。

I have a small VPS server that has a Nginx front end that serves up static media files and passes Django requests back to an Apache 2.2 prefork MPM server running mod_wsgi.

一(非常)小网站加载和工作,它是目前使用256MB的RAM 143MB。

With one (very) small site loaded and working, it's currently using 143MB of 256MB of RAM.

使用命令,我可以看到Apache是​​在第二使用2.1%使用可用RAM的52.9%,其中内存缓存。

Using the top command I can see that Apache is using 52.9% of available RAM, with memcache in second using 2.1%.

考虑到我计划把相当多的Django项目,这台服务器上,我想知道如果有什么我可以做修剪Apache是​​否使用的RAM数量?

Considering that I'm planning on putting quite a few Django projects on this one server, I'm wondering if there is anything I can do to trim the amount of RAM that Apache is using?

推荐答案

如果你想与Apache,提几点建议,坚持大致难度顺序:

If you want to stick with Apache, a few suggestions, roughly in order of difficulty:

  • use the Apache worker MPM instead of prefork. Real memory used per client connection will be lower, but be aware that the virtual memory allocated for Apache on Linux can appear very high, due to the 8MB Linux allocates for each thread's stack. This doesn't actually matter, unless your VPS is brain-dead and caps virtual memory rather than actual RSS (resident set size) memory. In that case you can learn how to lower the thread stack size here (under the Memory-constrained VPS section).
  • edit your Apache config file and reduce the StartServers, MaxClients, MinSpareThreads, and MaxSpareThreads settings roughly in proportion. The appropriate levels will be a balance between your desired memory usage and the number of concurrent clients you need to be able to serve.
  • switch to mod_wsgi (in daemon mode) instead of mod_python.

这篇关于Django的部署:切割Apache的开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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