HTTP Time out error when a report request is sent to a server following a table rebuild

Neil Brookes
Neil Brookes used Ask the Experts™
on
We've recently written a couple of reporting programs in PHP and Javascript for our own bespoke software that reads data from a table to return tonnage, sales, costs and margin by customer.
The table has a cron job that rebuilds the table twice daily, currenly at around 2am and then again around 1pm.
We find that the first user to run a report following a table update, that the server call times out returning a HTTP time out error on screen.
Is there a reason, that anyone knows of as to why it only happens on the first server call?
If we close down the window and re-open to run the report again it works without issue and get a normal response time of a couple of seconds.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
I have no idea why this might be happening, but here's a suggestion.  Immediately after rebuilding the table, have your cron job make a request to the server as if it were a user requesting the report.  With that "first request" out of the way, things might work smoothly.
Neil BrookesIT Developer

Author

Commented:
Thanks Ray, it's certainly worth looking in to and testing overnight.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Try rewriting your CRON job as follows...

1) Add debugging + logging logic to your CRON job to describe what's occurring.

2) Run a database repair on your specific database, something like this...

mysqlcheck --defaults-extra-file=/etc/mysql/debian.cnf --auto-repair -o your-database-name | egrep Error

You should see no errors.

3) Run your normal rebuild logic.

4) Run another database repair. Again you should see no errors.

5) Follow Ray's suggestion. Use curl or PhantomJS to exactly emulate the first user access. This include logging into your system + traversing through all pages. If JavaScript is involved, likely PhantomJS will be required.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial