I am working on a Google App Engine project (python/webapp2) where I am a little concerned with people abusing/spamming the service I am creating with a large number of requests. In an attempt to combat this potential, my idea is to limit the number of requests allowed per IP address in any given hour for certain parts of the applicaiton. My current plan is as follows:
On each request I will:
- grab the ip address from the header
- store this ip address in the dataStore with a time stamp
- delete any ip address entities in that are over an hour old
- count the number of dataStore entities with that IP address
- disallow access if there are more than given limit
My question is this:
Is this the best way to go about this? I am only a beginner here and I imagine that there is quite a bit of overhead of doing it this way and that possibly this is a common task that might have a better solution. Is there any better way to do this that is less resource intensive?