Reputation: 2497
I have a page with a Google map. On page load, there is only one marker and the user can dynamically add markers with a form.
I retrieve coordinates in database by using AJAX call. Each call return 150 markers. So, if I have to retrieve more markers, I do an other call until all markers are displayed on my map.
I have noticed (with load 2500 markers and firebug) time to execute server side action increases for each call.
Anyone can explain me why and if there is a way to fix it (because, at the end, calls take about 30s) ?
EDIT :
Execution time for each call (try to retrieve about 2500 markers) :
request 1 : 2.54s
request 2 : 1.83s
request 3 : 1.25s
request 4 : 1.31s
request 5 : 1.4s
request 6 : 1.81s
request 7 : 2.86s
request 8 : 8.25s
request 9 : 20.06s
request 10 : 19.25s
request 11 : 23.33s
request 12 : 25.86s
request 13 : 26.62s
request 14 : 27.85s
request 15 : 32.37s
request 16 : 34.91s
request 17 : 35.82s
request 18 : 36.7s
The function is exactly the same for each call and return value has same type and same length.
I do many calls in order to user can continue to work on map when markers are loading.
Upvotes: 0
Views: 406
Reputation: 212452
If you're using a session_start in the called script, then only a single call can execute concurrently because the session file is locked until the first call script terminates and releases that lock, or it's manually released with a call to session_write_close(), wherupon the next queued call can run and lock the file in turn.
It might be easier to use a single call to retrieve all the marker data in one go, rather than a lot of single calls for each group of 150 marker entries... this will bypass any session locking issues, because only a single script is being executed; and is also more efficient for the network overheads
Upvotes: 2