Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37670

Re: Downloading files and database connection

$
0
0
by Tomasz Muras.  

Checking and confirming this is quite simple:

  1. Check your current database connections.
  2. Start long file download.
  3. Notice additional DB connection hanging exactly until download finishes.

If you use Linux, you can slow down the transfer from your Apache to make it easier.

The solution to close the DB connection before file download works as expected but I'm not sure if we should be implementing it - the code around file downloads is complicated enough. Instead, there is actually a simple work-around - to use xsendfile (or friends). I've tested that on Apache: when the file is served, PHP process is killed, which closes DB connection. This works exactly when it should - that is, if you use accelerated download, you will never return back to the PHP code. We're handling $dontdie correctly (unless there is a bug there) - if it's set to true, download is not "accelerated".

So the question is: is it worth the effort of implementing closing DB connections for non-accelerated downloads?

cheers,
Tomek

Enovation Solutions


Viewing all articles
Browse latest Browse all 37670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>