1

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

Here is code for the view:

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

The template home/test_page.html is a 12.5 KB file.

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

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

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

arbz101
  • 325
  • 3
  • 14
  • I'd remove all template rendering and send the simplest 200 response to get a baseline, then read https://docs.djangoproject.com/en/1.11/topics/performance/. – jarmod Jun 16 '17 at 17:17
  • A plain 200 response takes 24.31 ms. I've read that particular page in great detail and tried pretty much everything suggested except for switching to jinja2, which I think would be overkill. – arbz101 Jun 16 '17 at 17:38
  • Are you running DEBUG mode (which suppresses the cached template loader)? Also, maybe investigate impact of different EC2 instance type (with more CPU and more RAM)? – jarmod Jun 16 '17 at 17:45
  • I went all the way up to an m3.xlarge instance, no improvement. I started a new Django project, and the situation described in my original question takes roughly 50ms. So, it probably has nothing to do with the server setup... I tried disabling all the extra middlewares as well... still nothing. – arbz101 Jun 16 '17 at 17:56
  • Did u get any solution? – Aaroosh Pandoh Nov 06 '20 at 20:27

1 Answers1

0

The problem was with an HTML minify middleware.

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

arbz101
  • 325
  • 3
  • 14