Django 性能,没有任何查询的 TTFB 很慢 [英] Django Performance, Slow TTFB Without Any Queries

查看:18
本文介绍了Django 性能,没有任何查询的 TTFB 很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个呈现 HTML 模板的简单视图.没有任何变量,也没有数据库查询.但是,我的TTFB 仍然是 665 毫秒.

I have a simple view which renders an HTML template. No variables whatsoever and no database queries. However, my TTFB is still 665ms.

这是视图的代码:

def test_page(request):
    return render(request, 'home/test_page.html')

模板 home/test_page.html 是一个 12.5 KB 文件.

我正在使用通过 Elastic Beanstalk 部署的 Amazon EC2 实例 (t2.medium).Django 1.8 版使用 python 3.4.

I'm using an Amazon EC2 instance (t2.medium) deployed with Elastic Beanstalk. Django version 1.8 using python 3.4.

由于我使用的是 Elastic-Beanstalk,所以服务器的配置是由 AWS 完成的.

Since I'm using Elastic-Beanstalk, The configuration of the server is done by AWS.

一个有趣的观察结果是,较小的文件(例如 4.1 KB 文件)为我提供了 145 毫秒的 TTFB.

An interesting observation is that a smaller file such as a 4.1 KB file gives me a TTFB of 145ms.

推荐答案

问题在于 HTML 缩小中间件.

The problem was with an HTML minify middleware.

这里是讨论这个问题的地方:https://github.com/cobrateam/django-htmlmin/issues/53

Here is where the issue is discussed: https://github.com/cobrateam/django-htmlmin/issues/53

这篇关于Django 性能,没有任何查询的 TTFB 很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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