I have been struggling with performance problems at webfaction for weeks 
now, and at
the moment I am stuck.

Locally I run web2py from source on Mac OS X 10.7.5, the data is stored in 
a Postgres database, to
which I connect using the following connection string:

db = 
DAL('postgres://username:password@localhost:5432/databasename',lazy_tables=True,
 
migrate_enabled=False, pool_size=1)

I distributed my table definition over 10 _db.py files each of which 
contain about 5 table definitions. Since I am not using Crud etc. I
adjusted the import statement:

## from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from gluon.tools import Auth, prettydate
auth = Auth(db)
## crud, service, plugins = Crud(db), Service(), PluginManager()

Locally I do not experience any performance problems at all.


At webfaction I used their installation script for web2py (it installed 
web2py version 2.4.6) and
I created a Postgres database. When I visit 
www.mydomain.com/init/default/index it takes
30 seconds or more to load the page! The index function just makes use of 
web2py's
templating system:

def index():
    response.title=APPNAME + ' - Homepage'
    return dict()


My first question is, when my application performs well locally, the cause 
of the problem cannot
be web2py or my application, can it?

This is what they say at webfaction:

Your site is behaving as if it is performing some really large database queries 
before returning the response to the user.  If I were you, I would use some 
logging 
or profiling to determine exactly where the bottleneck in the code is. I would 
accomplish 
this with 'print' statements with the current timestamp. Using that method, it 
is just a
 matter of time before you can accurately pin-point the source of any 
performance bottleneck.

Since you are using DAL, I think that database activity is a likely cause of 
this problem. Try 
to enable logging of all queries that get submitted to the database, and then 
use the 'explain' 
database command to understand how many rows each query is examining. If a 
query examines more 
than 25 rows, it needs to be optimized.
The index function does not perform a database query at all.

My application is completely node driven i.e I have a table 'node' which all 
other table reference by nodeID, besides the database just 
contains 50 nodes which are never retrieved at the same time.

How can queries that are fast locally be slow on webfaction's server?


Also be aware of any other external resources that your site is using. For 
example, if your site 
issues requests to other servers as part of the response, then this will also 
be a major performance 
bottleneck.

As far as I know I am not using any external resources other than this one:

<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' 
type='text/css'>


I am new to server management and hope someone can help me solve this problem. 
It's getting on my nerves since I am nearing a deadline.


Kind regards,

Annet.


-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to