Support for SermonSpeaker 5.x is in bugfix mode only, the same as it is for Joomla 3.10.
I will not add any new features to this releases.
Please upgrade to SermonSpeaker 6.x and Joomla 4.x, which is better anyway.

Sleeping Msql processes during audio download

More
11 Jan 2017 03:01 #6406 by Ken Lee
Dear Thomas,
I found that my web site Mysql server some times is clotted with processes in "Sleep" command" and NULL info field in "show processlist". The number of rows reaches the default maximum connection in Mysql (150) and Mysql stops accepting new connection.
I found those connections are very likely related to audio download action, because at the same time, I do netstat and got those IP addresses and search apache log, and saw them doing a lot of download/<sermonID> rows.
I suspect that somehow the code in downloading audio has opened a Mysql connection and wait to close after download is finished. e.g. $db = JFactory::getDBO(); in download() of controller.php. Would you kindly check if it can be modified?
Thank you a lot.
(I have to thank God and thank you that I have a site that is busy enough for this problem to arise.)

Ken

Please Log in or Create an account to join the conversation.

More
11 Jan 2017 08:15 #6408 by Thomas Hunziker
You could try and see if it makes a difference when you change the "exit;" to "JFactory::getApplication()->close();" in that method. That may be the cause since I don't properly terminate the Joomla application.

Please Log in or Create an account to join the conversation.

More
13 Jan 2017 13:04 #6412 by Ken Lee
Dear Thomas,
I needed to observe for some time after each change so I replied days later.
I did the change you suggested but there was no change.
I tried also:
adding
$db->__destruct();
right after $db->setQuery($query);
also no change in the accumulation of sleeping processes.

This sleeping process has become a problem since we upgraded our mp3 from 32kbps to 64kbps.
When our mp3 was 32kbps, the average number of sleeping process floated around 30 - 50, and I didn't regard it a problem.
Since we change to 64kbps from year 2017, the average number of sleeping process multipled. Attached please find the cacti graph.
Now I am thinking not using PHP to handle download but use Apache to force download of mp3 files (may be in a separate virtual host).
What would be your suggestion?
Thank you.
Ken
Attachments:

Please Log in or Create an account to join the conversation.

More
13 Jan 2017 16:11 #6413 by Thomas Hunziker
Another cause may be that someone starts downloading a file and it times out or the user cancels the download. Then the application likely isn't closed properly as well I think.

I don't know if you can tell Apache to force the download. My knowledge there is quite limited.
If you can instruct the browsers to download the file instead of open it then that would be preferred for sure.

Please Log in or Create an account to join the conversation.

More
17 Jan 2017 02:28 #6439 by Ken Lee
Dear Thomas,
I put this in my Apache configuration.
<FilesMatch "\.(?i:mp3)$">
ForceType audio/mpeg
SetEnvIf Request_URI "^.*/?([^/]*)$" FILENAME=$1
Header set Content-Disposition "attachment; filename=%{FILENAME}e"
UnsetEnv FILENAME
</FilesMatch>
And at view I took out the insertdlbutton and put this in
<a href="<?php echo $item->audiofile; ?>"><i class="icon-download"></i></a>

I did that at about 5:00PM. Referring to the chart attached, Sql connections also flattened since then.
From this observation I think the problem lies somewhere in the download function. However, I feel that the download function itself may not be the root cause. Because I cannot explain why there are repeating log entries for the same file, whether calling download() before or directly download the mp3 now.
By my gut feeling those repeating lines are not the result of "clicking the same download link many times", because the pattern of appearing is quite mechanical. Many repeating lines appear with almost regular intervals, and they happen across many client IP addresses. (I assume my audience are mostly not programmers.)
May be some Apache or browser engineers could answer my questions.
For now let me settle with what I did and see audience response. Thank you for your consideration.
Ken
Attachments:

Please Log in or Create an account to join the conversation.

More
17 Jan 2017 09:34 #6442 by Thomas Hunziker
It could be that a bot from a search engine activates the link, but doesn't really download the file. Then the script may time out I think and you would get an open MySQL connection until that times out as well.

I could add a parameter so admins can switch if the download should go through PHP or be a direct link. Since those download links are generated by the helper function, it should be easy to add.
The following user(s) said Thank You: Ken Lee

Please Log in or Create an account to join the conversation.

Time to create page: 0.155 seconds
Powered by Kunena Forum