Skip to main content

A rate limiter plugin for Falcon

Project description

falcon-ratelimit

================

Rate limiter for Falcon. Install with:

pip install falcon-ratelimit

Use like:

import falcon

from falconratelimit import rate_limit





class NoRedisResource(object):

    @falcon.before(rate_limit(per_second=5, window_size=30,

    resource='resource_name'))

    def on_post(self, req, resp):

        ...



class RedisResource(object):

   @falcon.before(rate_limit(redis_url='localhost:6379', per_second=1,

   window_size=10))

   def on_post(self, req, resp):

       ...

This package works by limiting the number of requests using two variables

per_second and window_size. In the first example above, the

NoRedisResource class is restricted to 5 requests per second over a 30 second

window meaning that there is a limit of 150 requests over 30 seconds. The

default storage of calling the rate_limit decorator is an in memory list to

store the number of requests for the given user using the resource

resource_name.

The second example implements the optional storage to use Redis by passing in a

redis_url to store user request data. Using Redis allows for the rate

limiting to be implemented across multiple instances of a particular

application. In the RedisResource class example the user is allowed to make

1 request per second over 10 seconds meaning that there is a limit of 10

requests over 10 seconds. Since this example didn't pass in a resource it

uses default as the name for request storage.

If you do not have the redis package installed, Redis-related functionality

will not work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

falcon-ratelimit-1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distributions

falcon_ratelimit-1.2-py3.8.egg (3.4 kB view details)

Uploaded Source

falcon_ratelimit-1.2-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file falcon-ratelimit-1.2.tar.gz.

File metadata

  • Download URL: falcon-ratelimit-1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0

File hashes

Hashes for falcon-ratelimit-1.2.tar.gz
Algorithm Hash digest
SHA256 b67b1be7c975b76bf8c6e594afe937193b09fee7b528667075c2a074f2c5cf4a
MD5 f6b7a71b812c3789ff49b738bb67dd62
BLAKE2b-256 8b37f58de70a609c9c3ca2f96e73d5eaab153efd26d0970f849f14922b075edd

See more details on using hashes here.

File details

Details for the file falcon_ratelimit-1.2-py3.8.egg.

File metadata

  • Download URL: falcon_ratelimit-1.2-py3.8.egg
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0

File hashes

Hashes for falcon_ratelimit-1.2-py3.8.egg
Algorithm Hash digest
SHA256 9c97f8995cd5a2fc46194fc3284c2336e9858ae1533f0f655f73912d81aa983f
MD5 f528524905c0b9cd5b26eb3adf07d292
BLAKE2b-256 42fcf08462c5d8a785973e14c1f25a0c47f136ff6d7cc0a75acf5c9350414fcb

See more details on using hashes here.

File details

Details for the file falcon_ratelimit-1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: falcon_ratelimit-1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0

File hashes

Hashes for falcon_ratelimit-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d732531d9baf9d75fd7259d7670f192b836a90e8805491a42846f1c145c68ecc
MD5 71f33b050048140b2e89349029f33f28
BLAKE2b-256 c3ceb78adc0d98c95d306bc093991c7531334fb7e2f9d8cb6a9cfc4e1bb68ae7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page