0

I am using a cloud database service, cloudant to be specific, it can let every user access directly to database with a good authorization system

However it is also a service that scale well and count billing by each and every access to server, 0.0015$ per 500 get request

So I was thinking about any service that will act like proxy or CDN or firewall, which I could limit user access frequency per minute

For example I would like to reject a user if that person make more than 20 requests per minute or more then 2 requests per second, something like that so I could protect some user try to flood request to my service

Are there any service like this? What it is called? And anything you may suggest me?

Thank you very much

Thaina Yu
  • 1,372
  • 2
  • 16
  • 27

1 Answers1

1

Some CDNs likely offer this, but you would have to contact their sales/support teams or check documentation. However, if you have access to a server where you can install nginx, it has request limiting features which might do exactly what you want.

It's in the "limit req" module. Some configurations that could work in your case:

http {
    limit_req_zone $binary_remote_addr zone=dbzoneip:10m rate=2r/s;
    # or limit_req_zone $binary_remote_addr zone=dbzoneip:10m rate=20r/m;
    # You can set this up if you want to limit total requests,
    # regardless of the incoming IP
    limit_req_zone $server_name zone=dbzoneserver:10m rate=100r/m;

    # this would be for whatever the path is to the db API
    location /db/ { 
       # now we use it
       # check docs to determine if you want to enable bursting
       # which allows you to buffer a small number of requests
       limit_req zone=dbzoneip; 

       # comment this out if you just want to limit particular users
       limit_req zone=dbzoneserver;

       proxy_pass https://url_or_ip_of_cloudant;
    }
}
Joshua DeWald
  • 3,079
  • 20
  • 16