I´m having a problem with a django site, sometimes my server stuck and
goes down. Just before it happens I receive about 200 traceback
messages telling me the same error: (1040, 'Too many connections'), I
get these messages in an interval of 1 minutes. I changed mysql
configuration and set the simultaneous connection limit to 1000 but
the problem persist. I´m not a mysql expert so I talked to my tecnical
support, they tell me mysql isn´t stucking the server, maybe it is the
traceback messages by email.
I disabled email traceback messages and this weekend my server goes ok
but I´m not fighting the problem this way. I have about 20 000 daily
visits (250 000 - 290 000 hits each day). This site is hosted on a
dedicated server, a Xeon 3.20GHz with 4GB of RAM space. I´m using
django-0.96pre and I use locmem as the cache backend. I´m using mysql
5.0.18 as database.
I have locmem configured with default parameters, when I start my
server it costs me about 800MB of RAM space, but now, after 10 days of
uptime, the consumed RAM is between 3.0GB and 3.4GB. I don´t send
emails from my server, except by the traceback and registration ones,
the registration is few number of emails.
I don´t know where should I look at to solve my problem. Some people
tell me to use a static index page server by apache, generated by a
cron job, do you think it´s really necessary? Does anyone is facing
such problem?
Any help will be greatfull,
Best Regards!
--
Michel Thadeu Sabchuk
The WebFaction guidelines someone else pointed to is a good start as
far as ideas to pursue, but some of these are Apache/mod_python
centric.
What web server arrangement are you using? Are you trying to use
inbuilt Django web server, mod_python, fastcgi, or something else?
Also perhaps post some of the traceback so it is more obvious to
people exactly what is raising the error about too many connections
and what call sequence triggered it.
Graham
First of all, thanks for all help, I was busy on a project last week
and could not dig into the problem.
Let me remeber the thread, I having a problem, sometimes my server
stuck and goes down, just before it happens, I receive many messages
telling "Too many connections". I use apache + mod_python combination
on a Suse server, the version of my package is:
apache2-mod_python-3.1.3-60
apache2-prefork-2.2.0-21.7
mysql-5.0.18-20.8
python-2.4.2-18.10
django-0.96-pre
MySQLdb-1.2.1_p2 [*]
[*] the version of MySQLdb is an older version that do not get messy
with my character set
I didn´t get any other stuck after august, 8 (my last message) but I´m
disabling traceback email messages on fridays and re-enabling on
mondays. The RAM usage oscilate between 1GB and 3GB during these
period, I think it is ok. I don´t use MaxRequestPerChild directive, is
it a good practise?
I read recomendations to change from apache+mod_python to apache
+mod_wsgi, this way I will have just one instance of python (am I
right?), reather than n instances created by apache/mod_python.
Thanks for all help!
I wrote the traceback bellow:
Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/django/core/handlers/
base.py", line 74, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib64/python2.4/site-packages/django/utils/
decorators.py", line 20, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/mrape/django/portal/common/views.py", line 56, in home
context['sponsored'] = (sponsored and sponsored[0]) or None
File "/usr/lib64/python2.4/site-packages/django/db/models/query.py",
line 100, in __len__
return len(self._get_data())
File "/usr/lib64/python2.4/site-packages/django/db/models/query.py",
line 430, in _get_data
self._result_cache = list(self.iterator())
File "/usr/lib64/python2.4/site-packages/django/db/models/query.py",
line 170, in iterator
cursor = connection.cursor()
File "/usr/lib64/python2.4/site-packages/django/db/backends/mysql/
base.py", line 100, in cursor
self.connection = Database.connect(**kwargs)
File "/usr/local/lib64/python2.4/site-packages/MySQLdb/__init__.py",
line 75, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib64/python2.4/site-packages/MySQLdb/
connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1040, 'Too many connections')
Don't understand what 0.96pre means since not a regular Django user,
but there was a whole issue with MySQL database issues with Subversion
copy of Django back in June.
http://groups.google.com/group/django-users/browse_frm/thread/588718d711a5a0f0/0b36765c27bfb5c9
Maybe the version you have incorporates that problem code.
Others may remember this issue and comment.
Graham
On Aug 17, 2:34 am, Michel Thadeu Sabchuk <miche...@gmail.com> wrote:
> Hi guys!
>
> First of all, thanks for all help, I was busy on a project last week
> and could not dig into the problem.
> Let me remeber the thread, I having a problem, sometimes my server
> stuck and goes down, just before it happens, I receive many messages
> telling "Too many connections". I use apache +mod_pythoncombination
> on a Suse server, the version of my package is:
>
> apache2-mod_python-3.1.3-60
> apache2-prefork-2.2.0-21.7
> mysql-5.0.18-20.8
> python-2.4.2-18.10
> django-0.96-pre
> MySQLdb-1.2.1_p2 [*]
>
> [*] the version of MySQLdb is an older version that do not get messy
> with my character set
>
> I didn´t get any other stuck after august, 8 (my last message) but I´m
> disabling traceback email messages on fridays and re-enabling on
> mondays. The RAM usage oscilate between 1GB and 3GB during these
> period, I think it is ok. I don´t use MaxRequestPerChild directive, is
> it a good practise?
>
> I read recomendations to change from apache+mod_pythonto apache
http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
You have one or more of these happening:
1) You have too many Apache children for the MySQL's max_connections
setting. You need to adjust the max_connections to match the number of
possible Apache child processes.
2) Something is stalling mysql threads. Use the SHOW PROCESSLIST
command to see what threads are around.
--Simon
Between releases, django.VERSION increments and adds the "-pre"
suffix, so "0.96-pre" would be a Subversion checkout of Django from a
point between the 0.95 and 0.96 releases (a current checkout will
report "0.97-pre"). That means it's at least a six-month-old checkout,
and probably a bit older (the window for such a checkout is roughly
August 2006-February 2007).
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
You mentioned the following:
> [*] the version of MySQLdb is an older version that do not get messy
> with my character set
Note that there is a problem with older versions of MySQLdb with
connections not being gargage collected.
See:
http://www.modpython.org/FAQ/faqw.py?query=2.24&querytype=simple&casefold=yes&req=search
I ran into this problem as well, upgrading to the most recent MySQLdb
seems to have done the trick.
Roger
First, thanks for the great help. I read your recomendations and fall
on 2 solutions:
1) Upgrade django to version 0.96. I see some people run into problems
with mysql (postgresql too), the recomended revision is [5511]. I don
´t work on this project (the site I´m keeping) from the starting, I
got it in the middle. It seems my django checkout is [3754] from
2006-12-09.
On the same thread, the problem seems to be raised on the [5482]
django release, this way I think the problem isn´t with my django
instalation. I didn´t upgraded my django version because I planning to
upgrade/rewrite my whole project using newforms/newforms-admin, I don
´t know if there will be any side effect migrating to 0.96, so I
focused my efforts to another points.
Anyway, running a `mysqladmin proc` tells that the connections are
closed properly, almost anytime I run the command, it shows me only
the mysqladmin connection.
2) Upgrade MySQLdb lib. I had problems with newer versions of this lib
(problems with unicode), I used webware+sqlobject. Do you think this
will really solve my problem? I just wonder if I will solve a problem
and raise another one (with character encoding :-P)
Thanks for all help!
Best regards,