Slow first time access on production with Ubuntu/NGINX/UWSGI

237 views
Skip to first unread message

Jim S

unread,
Aug 20, 2014, 1:32:34 PM8/20/14
to web...@googlegroups.com
Hi

I've installed web2py on my ubuntu machine using the script at the bottom of this section in the book:


It is all working well except for one annoyance.  

If I leave the let the page site for a while (haven't really determined the time period needed to display the behavior), when I come back later my first access to the application is really slow, like 10 seconds to display the page.  But, after that, it clicks along with sub-second response time.

Anyone have any idea what is going on or where to begin trouble-shooting?

-Jim

Richard Vézina

unread,
Aug 20, 2014, 3:24:06 PM8/20/14
to web2py-users
Could your app take time to create global vars and after they are cached up?

Richard


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Aug 20, 2014, 3:26:35 PM8/20/14
to web2py-users
You can check that with profiler : python web2py.py -a 'asdf' -i 127.0.0.1 -p 8000 appname -F fileNameForProfilerDumpInfo'

Your app will be very slow with profiler.

Richard

Niphlod

unread,
Aug 20, 2014, 3:38:44 PM8/20/14
to web...@googlegroups.com
seems to me that the problem could be uwsgi not being active at the time the first request comes in.... how did you configured it ?

Jim Steil

unread,
Aug 20, 2014, 3:47:46 PM8/20/14
to web...@googlegroups.com
Niphold - I didn't do any configuration of uwsgi other than what comes with the script from the book.

Richard - What will the profiler tell me?  I've never used it before?  How do I read the output?

-Jim


You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/3tmtJeQW9GI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Jim S

unread,
Aug 20, 2014, 4:49:28 PM8/20/14
to web...@googlegroups.com
I did this and after waiting 45 minutes and re-testing, it did not exhibit the slow behavior.  Since this is a test without running nginx/uwsgi I'm assuming my problem is in one of those layers.

Also, I access the production site with http instead of https, the slowness isn't there either.

-Jim

Cliff Kachinske

unread,
Aug 20, 2014, 10:17:54 PM8/20/14
to web...@googlegroups.com
The install script in the book may not be correct for your version of Web2py.

A good first step might be to check the script's config settings against the ones from the book.

Richard Vézina

unread,
Aug 21, 2014, 10:45:00 AM8/21/14
to web2py-users
The profiler tell you the time spent on what, so it a good start for code improvement. But if you were not experimenting the slowmotion in other configuration (other VM) it shouldn't be your code but uwsgi/nginx config as stated by Niphold.

Richard

Jim Steil

unread,
Aug 21, 2014, 10:47:04 AM8/21/14
to web...@googlegroups.com
I've changed the following in /etc/nginx/sites-available/web2py

ssl_session_cache shared:SSL:10m;    -> to 60m
ssl_session_timeout 10m;   -> to 60m

Still took a long time (5-10 seconds) for the first request but maybe now it will not cause that to happen again for greater intervals.

-Jim


You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/3tmtJeQW9GI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Richard Vézina

unread,
Aug 21, 2014, 11:08:32 AM8/21/14
to web2py-users
I have 10m and I don't have this issue...

I don't think it coming from nginx.

There is very few parameters in nginx config that could explain your latency...

Does it happen only on reboot of VM, or it happen when you restart nginx, or uwsgi. What happen if you restart nginx only vs restart uwsgi only. And what happen if you try to start manually uwsgi after reboot of the VM before first aptempt to connect to your app. Maybe uwsgi is not started and get strat by nginx, that should not be the case though, they have both to be strated independently.

You can try your app in other VM and determine if the latency was there or not.

All these test can help you figure out where to dig up further.

Richard


Jim Steil

unread,
Aug 21, 2014, 11:21:38 AM8/21/14
to web...@googlegroups.com
uswgi restart - no delay

nginx restart - about a 12 second delay for the first request if running https

nginx restart - no delay if running http

-Jim

Jim Steil

unread,
Aug 21, 2014, 11:23:09 AM8/21/14
to web...@googlegroups.com
Clarification - the uwsgi restart had no delay on the first request running https or http

-Jim

Richard Vézina

unread,
Aug 21, 2014, 1:05:50 PM8/21/14
to web2py-users
Ok, what I was about to wrote before I doubt of me.

Maybe your issue come from bad nginx syntax for permanent redirection from HTTP to HTTPS...

Mine redirect like that :


Richard

Jim Steil

unread,
Aug 21, 2014, 1:19:34 PM8/21/14
to web...@googlegroups.com
I'm not doing and redirecting from http to https.  It's just when I specify https that I'm getting the symptoms.

I don't think I'm doing any re-writing.  At least there is nothing there that I setup  Would that be in the same file?  /etc/nginx/sites-available/web2py

Richard Vézina

unread,
Aug 21, 2014, 1:25:49 PM8/21/14
to web2py-users
If your url is http when page charged completly there is no redirecting.

If it related to your SSL certificate or nginx conf, I am far from an expert. I would say that if it long only for the first time it is not related to the overhead of encryption for your server... So you have to investigate about nginx certificate configuration... Because if you have poor processing capability SSL would be slow every request.

Sad that I can't help further.

:(

Richard

Jim Steil

unread,
Aug 21, 2014, 1:27:21 PM8/21/14
to web...@googlegroups.com
You've already done way more than I could have hoped.  I'll see what I can find regarding ssl slow-down with nginx and report back.

Thanks for all the help.

-Jim
Reply all
Reply to author
Forward
0 new messages