Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl-rest
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl-rest
Commits
92bbeeae
Commit
92bbeeae
authored
11 years ago
by
Andy Yates
Browse files
Options
Downloads
Patches
Plain Diff
Forgot the right config
parent
2160511c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
configurations/production/ensrest.psgi
+14
-29
14 additions, 29 deletions
configurations/production/ensrest.psgi
with
14 additions
and
29 deletions
configurations/production/ensrest.psgi
+
14
−
29
View file @
92bbeeae
...
...
@@ -7,7 +7,6 @@ use File::Basename;
use File::Spec;
use Plack::Builder;
use Plack::Util;
use Plack::Middleware::Throttle::Backend::Memcached;
my $app = EnsEMBL::REST->psgi_app;
...
...
@@ -25,19 +24,13 @@ builder {
my $rootdir = File::Spec->rel2abs(File::Spec->catdir($dirname, File::Spec->updir(), File::Spec->updir()));
my $staticdir = File::Spec->catdir($rootdir, 'root');
enable 'Throttle::Hour' => (
code => 429, #Code is HTTP response code for "Too Many Requests"; alternatives include 420 (Twitter; "Enhance your calm")
max => 11100, #11100 requests per hr (~3 per second)
backend => Plack::Middleware::Throttle::Backend::Memcached->new(
driver => 'Cache::Memcached',
expire => 3601, #Expire set to 1hr and 1 second
args => {
servers => ['127.0.0.1:11211'],
no_rehash => 1,
namespace => 'ensrest:throttle_3pr_hr:',
debug => 0,
}
enable 'EnsThrottle::Hour' => (
backend => Plack::Middleware::EnsThrottle::MemcachedBackend->new(
memcached => Cache::Memcached->new(servers => ['127.0.0.1']),
expire => 2,
),
max_requests => 11100, #1100 requests per hr (~3 per second)
client_id_prefix => '3rps_hour',
message => 'You have exceeded your limit which is 11,100 requests per hour (~3 per second)',
path => sub {
my ($path) = @_;
...
...
@@ -46,25 +39,17 @@ builder {
return 0;
}
);
enable 'Throttle::Second' => (
code => 429, #Code is HTTP response code for "Too Many Requests"; alternatives include 420 (Twitter; "Enhance your calm")
max => 6, #6 requests per second
#add a second to the Retry-After header value. Means when we burst the 6 per second
#we force a user to wait for an additional second (so effectivley they run at 3 req per second)
retry_after_addition => 1,
backend => Plack::Middleware::Throttle::Backend::Memcached->new(
driver => 'Cache::Memcached',
enable 'EnsThrottle::Second' => (
backend => Plack::Middleware::EnsThrottle::MemcachedBackend->new(
memcached => Cache::Memcached->new(servers => ['127.0.0.1']),
expire => 2,
args => {
servers => ['127.0.0.1:11211'],
no_rehash => 1,
namespace => 'ensrest:throttle_6pr_second:',
debug => 0,
}
),
max_requests => 6,
client_id_prefix => '6rps_second',
retry_after_addition => 1,
message => 'You have exceeded the limit of 6 requests per second; please reduce your concurrent connections',
path
=> sub {
path => sub {
my ($path) = @_;
return 1 if $path ne '/';
return 1 if $path !~ /\/(?:documentation|static|_asset)/;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment