WebFaction
Community site: login faq

Only one of my several apps hosted here suffers lag on first request after an inactivity period. Over 10 seconds to get reply.

Issue is not with database, it is with python itself ( checked with newrelic ).

I have read Django app seems very slow to start up (10+ seconds) but this is not my case, I use WSGIImportScript and after reboot first reply is fast. In my case, issue is after inactivity period.

I have checked memory to ensure it is not a swapping problem, but I'm within my memory limits.

This is my wsgi config:

import os
import sys
import site
import newrelic.agent

site.addsitedir('/home/x/webapps/x/venv/lib/python2.7/site-packages/')

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'x.settings'

activate_this = os.path.expanduser("/home/x/webapps/x/venv/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
newrelic.agent.initialize('/home/x/webapps/x/newrelic.ini','x')
application = WSGIHandler()
application = newrelic.agent.WSGIApplicationWrapper(application)

And here apache config:

ServerRoot "/home/x/webapps/x/apache2"

LoadModule dir_module        modules/mod_dir.so
LoadModule env_module        modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module       modules/mod_mime.so
LoadModule rewrite_module    modules/mod_rewrite.so
LoadModule setenvif_module   modules/mod_setenvif.so
LoadModule wsgi_module       modules/mod_wsgi.so

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/x/logs/user/access_x.log combined
ErrorLog /home/x/logs/user/error_x.log
KeepAlive Off
Listen 29999
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIImportScript /home/x/webapps/x/wsgi.py process-group='%{GLOBAL}' application-group='%{GLOBAL}'
WSGIDaemonProcess x processes=2 threads=12 python-path=/home/x/webapps/x:/home/x/webapps/x/x:/home/x/webapps/x/venv/lib/python2.7/site-packages:/home/x/webapps/x/lib/python2.7
WSGIProcessGroup x
WSGIRestrictEmbedded On
WSGILazyInitialization Off
WSGIScriptAlias / /home/x/webapps/x/wsgi.py

asked 10 May '14, 09:15

MrFlorrick
1113
accept rate: 0%

edited 10 May '14, 09:24

Have you attached a debugger to the process to see what is going on? Based on your description of inactivity you are seeing what the community post describes.

The ultimate answer will come after knowing exactly what your process is waiting on that can only be done via the debugger.

(10 May '14, 11:19) aaront ♦♦

@aaront, are you talking about debug toolbar? When you say debugger, what are you talking about? (some link?)

(10 May '14, 11:28) MrFlorrick

While the debug toolbar is very good there are other options that you should use for this issue. You can find some different options at the link below.

https://code.google.com/p/modwsgi/wiki/DebuggingTechniques

(10 May '14, 11:33) aaront ♦♦
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×904
×26

question asked: 10 May '14, 09:15

question was seen: 4,226 times

last updated: 10 May '14, 11:33

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM