Properly configuring and using Drupal's views_data_export module

In a Drupal view, I have a button in place that allows the user to export the current view to an Excel (XLS) download (utilizing views_data_export module functionality). That download is expected to be around 3,500 rows, with 39 columns. I just noticed that trying to hit that button for the download results in (almost exactly 30 seconds later) an error I hadn't seen before: "Server Hangup".

I also noticed the apache2 process, while that export was spinning up, was occupying 100% of the CPU. Since this appeared to be a timeout issue, I tried modifying the max_execution_time setting in php.ini from 30 seconds to 60 seconds.

With that change in place, I then got a Connection Timed Out error at the 60 second mark. I modified the max_execution_time to 75 seconds, but still got that Connection Timed Out error at 60 seconds.

So...then I had an RTFM moment with the views_data_export module. It seems that, when I set it up in my view, I didn't realize the beauty of the 'batching' concept that it provides. For smaller data sets, the module can build the export in one 'go' - this is what I was originally doing, and is represented in the 'top' option in the photo below. For larger datasets, you really need to turn on batching (the second "small segments" option in the photo below).

views_data_export module settings

One last note about that 'batch size' setting: I had good success with a size of 100, then tried 500 and got the Server Hangup error again. Depending in the capability of your server, it might take a little effort to find the right settings for your application.

Tags: 

2017-03-15, 11:03 am