Django performance tuning notes
- 内存、内存,还是加内存
- 使用单独的静态文件服务器
- 关闭KeepAlive(如果服务器不提供静态文件服务,如:大文件下载)
- 使用memcached
- 使用select_related()加载关联表数据
- 使用values()过滤不必要的字段查询
- 使用模板cache
- 加载编译的模板,例如下面代码并非直接用
render_to_response
from django.template import loader
from django.http import HttpResponse
# Loads and compiles the template
myview_template = loader.get_template('path/to/template.html')
def myview(request):
# do something
return HttpResponse(myview_template.render(context))