I have a php 5.5 web app using the Symfony2 framework and would like to keep the server load at a minimum. A few pages on my site allows the user to retrieve a list of objects from a database and one set has several hundred thousand rows, and will be over a million soon. Unregistered users are able to use this page.
I want to prevent the user from performing a query too many times in a minute or some similar timespan and have seen this implemented on other websites, including stackoverflow for comments or voting.
How is this implemented? Do I need to create a cookie and check the session on each page load to see if the specific actions I want to limit have been used and prevent the form submission? Is there a standard way of handling this in php, or specifically for Symfony2? I have searched for this and found some similar questions, but no specific answer. This is for users directly on my site and not using an api.
How to throttle API requests using PHP
How do I throttle my site's API users?
Edit:
I know cookies are not the proper way to go and will try to implement a mechanism using a cache. I'm using php 5.5 and read that APC has some bugs with 5.5, therefore Zend OpCache is actually preferred along with APCu. Can anyone show an example of using Zend OpCache / APCu to log and track user requests?