I am trying to improve page performance by including asynchronous requests to show content independent of each other. So, for example, I have two content placeholders, placeholder 1 and placeholder 2 on my page. When page loads (on ready), I sent two asynchronous requests to actions (in same controller) to return data. These actions make web service calls using curl and return data. But, when I make asynchronous calls, I don’t see them executing in parallel. Instead, first action is making webservice call and once first actions is executed completely, then second action starts executing. This is not helping in reducing content load time. Can someone please suggest to how to execute requests in parallel so that I can improve content load time on my pages.
I’m pretty sure it’s the default session implementation in PHP (file based), you’ll need to use a DB or other session implementation to get around it. If you use PHP sessions, frames can’t even load in parallel.
Thanks for the reply. I am following Service based development. I don’t have DB available to use it for sessions. Is there any other way I can get around this? If I completely avoid using sessions in these two actions, then is it going to help me achieve running concurrent requests?
Yeah if you can make sure Yii doesn’t initialise any sort of session handling then it should operate in a concurrent fashion. However any code calling session_start() will have to wait because each request will end up waiting on a file system lock.
I tried adding session_write_close() as first statement in both actions I call asynchronously from browser. But, I still see them executing in sequential order instead of concurrent execution. These two actions do not access/write to session after executing session_write_close() statement. I was writing trace statements to log file to see if they are really executed in parallel. But, then thought using same file for logging from both actions can again make other script wait. So, used different log files and verified timestamps. But, they are still not executed in parallel. I’m running out of ideas. Can anyone suggest how can achieve concurrent execution of actions without using DB for session handling mechanism.