Hi all,

I'm developing a tool in which I'm using* Angular 6* for frontend and *Django 
rest framework* for the backend. To connect Django and MySql I'm using 
*SqlAlchemy*.

Now, I'm facing issue "*MySql Too many connections"* when there is an 
increase in usage of API or you can say no. of users(currently 10 users). 
When I see *show processlist* all the connections are in sleep. when no. of 
connections reaches maximum I'm getting this error. So I tried using 
connection pooling to solve this issue (link 
<https://pypi.org/project/django-db-connection-pool/>). But still not able 
resolve as the connections are continuing to be in sleep mode. I have also 
tried giving 'CONN_MAX_AGE' as 0 but of no use.

1) Why is Django not closing the connections or reuse the connections which 
are in sleep instead of creating a new connection every time?
2) Should I close the connections manually? How?
3) The proper way to handle the connection pooling in Django.
4) Any other ways to handle this issue?

*Quick fix*: I have set wait_timeout and interactive_timeout as 800 for 
temp purpose and it is working fine as the connections which are in sleep 
mode for more than 800s are getting dropped. I feel this is not a proper 
way to fix this issue.

I have posted this issue on stack overflow(link 
<https://stackoverflow.com/questions/58080545/mysql-too-many-connections-django-sqlalchemy>)
 
but haven't got any response.

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9bf85bbd-21c7-4ff9-8fd2-1c578ba5c9f9%40googlegroups.com.

Reply via email to