Exceeding memory limits in webfaction

165 views
Skip to first unread message

Jose

unread,
Oct 23, 2011, 6:31:25 PM10/23/11
to web2py-users
Hello

I have some applications in webfaction (more than 2 years).

I recently upgraded web2py to version 1.98.2 and then to 1.99.2.

What I noticed is that since the first update errors began to appear:

502 – Bad Gateway

I reported this to webfaction and they answered that it is because it
exceeds the memory limit to my plan:

"It appears that you are regularly exceeding your memory limit of
80MB. This leads to your processes getting killed, and therefore your
backend web server is not working until it gets restarted. This is the
reason for the 502 errors."

As I said, this started after upgrading web2py.

How I can solve this problem?

best regards
Jose

Massimo Di Pierro

unread,
Oct 23, 2011, 6:53:13 PM10/23/11
to web2py-users
Can you try run your app locally with 1.99.2 and see if you can
reproduce any memory problem. What version did you upgrade from? Di
you have also with 1.98.2? I cannot think of any change that results
in more memory usage, actually the opposite.

Massimo

Jose

unread,
Oct 23, 2011, 7:05:59 PM10/23/11
to web2py-users


On 23 oct, 19:53, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> Can you try run your app locally with 1.99.2 and see if you can
> reproduce any memory problem. What version did you upgrade from?

I do not remember, but I'm sure it was a version of more than 1 year.

Jose

annet

unread,
Oct 24, 2011, 3:19:20 AM10/24/11
to web2py-users
Hi Jose,

I had the same problem a week ago, Sean solved it doing the following:


In the Control Panel, under Domains/websites Applications, add a new
Application:

Name: init_static
App category: Symbolic link
App type: Symbolic link to static-only app
App doc: This creates a symlink from ~/webapps/<app name> to the
absolute path specified in the extra info field.

This application treats the contents of the path specified in the
extra info field as if it were a Static-only application. The files
within are served by a shared web server process (typically nginx).
This application is exclusively static; PHP files and .htaccess files,
for example, will not be interpreted.

Note: Once the application is created, the path cannot be edited. To
change the path, delete the application and recreate it.

Extra info: /home/account_name/webapps/application_name/web2py/
applications/init/static


Click Create.




Under Domains/websites Sites, add a new Site app to the existing site:

Site apps:
App: select init_static from the drop down list.
URL path (ex: '/' or '/blog'): /init/static


Click Update


This reduces your RAM usage below 40 MB.


Kind regards,

Annet.

Jose

unread,
Oct 24, 2011, 6:34:02 AM10/24/11
to web2py-users
Hello Annet

I did what you suggested, but does not quite understand. I guess I
should repeat the process for each of the applications I have in the
hosting.

My directory structure is:
my_account/webapps
my_account/web2py

the path is as follows:
/home/my_account/web2py/applications/my_app/static

Should I change something in httpd.conf?

thank you very much
Jose

Johann Spies

unread,
Oct 24, 2011, 6:46:37 AM10/24/11
to web...@googlegroups.com
Should I change something in httpd.conf?


When I did it some weeks ago the support people of Webfactional was very helpful.  I did not have to do something to the apache-setup.   The creation of this static-only app did not solve my problem and in the end I have switched to a uwsgi-setup.  A search in this mailing list's archives will provide a lot of information on that setup.

Regards
Johann

--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Jose

unread,
Oct 24, 2011, 8:07:01 AM10/24/11
to web2py-users


On 24 oct, 07:46, Johann Spies <johann.sp...@gmail.com> wrote:
> Should I change something in httpd.conf?
>
> When I did it some weeks ago the support people of Webfactional was very
> helpful.  I did not have to do something to the apache-setup.   The creation
> of this static-only app did not solve my problem and in the end I have
> switched to a uwsgi-setup.  A search in this mailing list's archives will
> provide a lot of information on that setup.
>
> Regards
> Johann
>

Hello Johann

I commented your suggestion to webfaction and recommended read this
[1]

[1] http://community.webfaction.com/questions/143/uwsgi-for-better-performance-and-memory-usage

annet

unread,
Oct 24, 2011, 10:05:52 AM10/24/11
to web2py-users

> I did not have to do something to the apache-setup. The creation
> of this static-only app did not solve my problem and in the end I have
> switched to a uwsgi-setup. A search in this mailing list's archives will
> provide a lot of information on that setup.

When I was having memory problems, I asked webfaction's support people
why they do not make the Nginx+uwsgi configuration the default, this
was their reply:

"If you're referring to the Nginx+uwsgi configuration mentioned in
that post, I
think our installer was developed before uwsgi was considered to be
stable
enough for use.

We find that our mod_wsgi installer meets the majority of our
customers needs,
but if there is enough demand for a Nginx+uwsgi installer, we'll look
into
adding one.

Regarding the memory usage of your w2p app, you can reduce that quite
a bit by
using a static-only symlink app to handle the static media for your
site."


At the moment I am no longer experiencing memory problems, should I
switch to Nginx+uwsgi before hand?


Kind regards,

Annet.


By the way. Vasile Ermicioi provided me with this step-by-step set up
of Nginx+uwsgi:


1) Create a custom app 
Category: Custom
Type: Custom listening on a port

2) [web2py]
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip  
cd web2py
python2.7 web2py.py #seems needed before using it
ctrl+d #stopping it
cd .. #back to home directory

3)  [uwsgi]
wget http://projects.unbit.it/downloads/uwsgi-0.9.9.2.tar.gz
tar xvzf uwsgi-0.9.9.2.tar.gz
cd uwsgi-0.9.9.2
/home/your_name/bin/python2.7 uwsgiconfig.py --build
mv uwsgi /home/your_name/bin
cd .. #back to home directory

4)
uwsgi --http 127.0.0.1:your_app_port --pythonpath /home/your_name/
web2py --module wsgihandler -d /home/your_name/tmp/uwsgi.log -t 20 --
async 16 --ugreen --limit-as 64 -r --no-orphans -M -p 1 --touch-
reload /home/your_name/tmp/uwsgireload.txt --reload-on-rss 50

annet

unread,
Oct 24, 2011, 1:37:30 PM10/24/11
to web2py-users
I submitted a ticket at webfaction, this is their reply:

"That is correct, this does not completely prevent the problem from
recurring.
Using a static-only symlink app is just a step in helping with the
memory
usage. In order to solve the memory issue, you would need to find the
root
cause of the memory usage. You can do this by following the steps
outlined
here: http://docs.webfaction.com/software/general.html?highlight=memory
%20usage#reducing-memory-usage

Using Nginx+uwsgi may reduce your memory usage, but it will involve
some
experimentation with your application. If you want to try installing
Nginx+uwsgi, I would create a new application and try the
installation
following the steps outlined in that community post. This way you can
still have
your existing site online while you are install the new uwsgi
application. The
technologies are similar, but uwsgi is newer and has been known to use
less
memory."


Annet.

Jose

unread,
Oct 28, 2011, 11:23:13 AM10/28/11
to web2py-users
After creating the Symbolic link I have not had any problems. I hope
that continues.

thanks annet

Jose
Reply all
Reply to author
Forward
0 new messages