Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

freshnet

macrumors newbie
Original poster
May 15, 2011
18
0
Calgary, Canada
I recently set up several different web projects that I'm working on locally using PHP 5.6 and MYSQL 5.6. One of the sites uses an API. I thought that this site was running slowly, then I realized that any other localhost pages would finish what they were doing first (i.e. if I load 3 pages on localhost, page 3 doesn't start actually running until pages 1 and 2 are finished. All the sites are in different folders, using different databases (if any), but this happens even if I try to load 2 pages in the same site. Is there any way around this? I think I could set up multiple localhosts, but actually the main problem is multiple requests with the same site being queued. This is definitely a problem outside the code: I checked MYSQL and the connection to the database isn't even made for the 2nd page until the 1st page finishes.

I hope I explained that ok!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I honestly don't know what webserver OS X ships with anymore, but this is your bottleneck. There is a max connection or worker count that is limiting simultaneous page loads. This is generally to reduce resource usage, especially on a normal desktop setup. You should be able to reconfigure this, but I'm not sure how these days based on what server is running. A Google for "increase connections web server OS X 10.X" where X is your OS version ought to lay it out.
 

freshnet

macrumors newbie
Original poster
May 15, 2011
18
0
Calgary, Canada
Thanks for pointing me in the right direction! After a lot of reading about this, e.g. http://stackoverflow.com/questions/1430883/simultaneous-requests-to-php-script, I found that the bottleneck is in fact PHP. I was able to show this by writing a quick PHP script on localhost that waits for 5 seconds, then loading an html file on localhost while it was running. The html file loaded instantly, which showed this was PHP.

There are a couple of workarounds, what I am doing is using vcap.me (which resolves to localhost) and hitting a different url with each page, e.g. 1.vcap.me/test.php, 2.vcap.me/test.php.

thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.