I am building my own analytics platform, which I want to work like this... A JS script in each of my webpages collects data about users' clicking behaviors and sends that data to a PHP (or other convenient language) script on my server. This server-side script receives the data from the first AJAX request and stores it in a variable. Then, since there is another AJAX request waiting, the server-side script receives the data from that AJAX request and stores that in a variable. Then, when not many AJAX requests are waiting, the server-side script takes the data which is now stored in variables and inserts it into a MySQL (or similar) database. Finally, the server-side script removes all of those variables from memory (because they are no longer needed), and waits for more AJAX requests to come in. What is the best way to accomplish what I have described here?