CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript, Python code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Thu Mar 28, 2024 10:34 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: php script sometimes takes a long time to execute
PostPosted: Thu Nov 02, 2017 11:33 am 
Offline

Joined: Tue Feb 28, 2017 9:27 am
Posts: 1
I'm a high school teacher. I wrote an HTML/Javascript program that lets students submit their answers to an assignment using AJAX and a server-side PHP script.
Then there is another HTML program that calls a different PHP script, which generates a Leader Board, so I can display their scores on the projector. This lets the students compete for high score.
more: eco dream
The HTML page calls on this PHP script every 2 seconds, so the Leader Board constantly updates.

The basic logic of the PHP script is:
Parse $GLOBALS['HTTP_RAW_POST_DATA'] into assignment name and class list
For each student, read a file which contains their score on that assignment.
Organize this data and echo it.

When I first open the Leader Board, it sometimes loads right away, but sometimes it can take several minutes, even causing the browser to kill the page.
But once it finally works, it remains working. Every 2 seconds, the PHP is called again, and it generates its response within milliseconds. The huge delay is gone.
If I close the tab that has the Leader Board, and open it again within a few minutes, it loads immediately. But if I wait an hour and open it again, I again get the huge delay the first time the PHP is called.
more: chung cư pcc1 thanh xuân
For debugging, I had the PHP also output the time at various points in the code. Reading the file that contains the classlist and the file that contains the assignment were each done in under a second. But reading each students' grades takes about 2-3 seconds per student. But after the first execution of the PHP, it reads all 30 students grades in less than 1 second.

I've used this program for 4 years with no issues. But this summer, I bought a new domain name and a hosting plan from the same company as my original plan. I transfered all the files over, and everything was smooth and worked exactly like last year, except for this annoying delay.

Edit:
If I open the Leader Board on one computer, wait for the delay to pass, close it, and then open it on another computer within a few minutes, there is no delay on the 2nd computer.
more: dự án eco dream
It's hosted on a Linux server.

Any idea why it takes so long to read file contents the first time?
Thanks!


Last edited by adamjohnson on Sat Nov 04, 2017 6:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: php script sometimes takes a long time to execute
PostPosted: Fri Nov 03, 2017 7:02 am 
Offline
Site Admin

Joined: Wed Sep 12, 2007 2:18 pm
Posts: 3931
Hi.

We will try to help if You provide us with your source code.

Thanks,
Codelobster Team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2016 phpBB Group