0

Right now, I have developed an android app that is available free on the market. The app basically uses HTTP GET to query some data from my personal server. I'm a wee bit worried about bandwidth as my server is hosted and thus has limited monthly transfer.

I was just wondering, is there a robust way to limit the number of requests made by each user per day, say, to 20 requests?

For some background, the app interface is pretty straightforward. Two EditText boxes to capture the HTTP GET parameters and a Button to submit the request. This eventually returns some values from a cgi script which populates a TextView on the app.

Solutions can be either on app end or server end. An idea I had was to somehow write the number of requests already made to a file and reading the status from there.

Are there better ways of achieving what I want?

Reuben L.
  • 2,806
  • 2
  • 29
  • 45

1 Answers1

1

Just a suggestion:

In your APP:

Generate a unique id for each device (see this question.) and send it to the server with the request.

In your server:

store requests count from each device somewhere and apply any limitation you want based on the stored value.


Note that you could limit the requests by IP on server side. The problem with this approach is you're also limiting the users connected to the internet with a shared IP (ex. multiple devices connected to an access point, etc.)

Community
  • 1
  • 1
fardjad
  • 20,031
  • 6
  • 53
  • 68
  • Thanks for the answer. Would you have any idea how the limitation could be applied on the server end? – Reuben L. May 12 '12 at 08:41
  • Store the requests count for each user (DeviceID) on a database table (and reset the values everyday using a cron job). Then on each request check the DeviceID and send an error response if requests exceeded allowed requests count. – fardjad May 12 '12 at 08:47
  • thanks! i've done something slightly more primitive - appending the unique id to a txt file and using a cron job to empty it daily. everytime a user queries, i will grep the txt file and do a wc -l to check if the limit has been reached. – Reuben L. May 12 '12 at 09:13