-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Rack attack #1419
[feature] Rack attack #1419
Conversation
@Pralish please also investigate why the server is unhealthy after terminating a request from rack-timeout. The request times out: A Rack::Timeout::RequestTimeoutException occurred in content#show:
Request ran for longer than 15000ms
config/initializers/rack_timeout.rb:21:in `call' and the puma Server hangs, and is unable to serve subsequent requests EDIT: Redis connection timeouts are causing the server to crash as well: A Redis::TimeoutError occurred in background at 2023-02-28 00:12:35 UTC :
Connection timed out
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:58:in `block in _read_from_socket'
-------------------------------
Backtrace:
-------------------------------
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:58:in `block in _read_from_socket'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:54:in `loop'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:54:in `_read_from_socket'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:47:in `gets'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/connection/ruby.rb:382:in `read'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:311:in `block in read'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:299:in `io'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:310:in `read'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:161:in `block in call'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:279:in `block (2 levels) in process'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:420:in `ensure_connected'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:269:in `block in process'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:356:in `logging'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:268:in `process'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:161:in `call'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:257:in `block in call_with_timeout'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:331:in `with_socket_timeout'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/client.rb:256:in `call_with_timeout'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis.rb:269:in `block in send_blocking_command'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis.rb:268:in `send_blocking_command'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/commands/lists.rb:270:in `_bpop'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-4.6.0/lib/redis/commands/lists.rb:167:in `brpop'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-namespace-1.8.2/lib/redis/namespace.rb:476:in `call_with_namespace'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/redis-namespace-1.8.2/lib/redis/namespace.rb:352:in `block (2 levels) in <class:Namespace>'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/fetch.rb:47:in `block in retrieve_work'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq.rb:100:in `block in redis'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:63:in `block (2 levels) in with'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:62:in `handle_interrupt'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:62:in `block in with'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:59:in `handle_interrupt'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:59:in `with'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq.rb:97:in `redis'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/fetch.rb:47:in `retrieve_work'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/processor.rb:83:in `get_one'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/processor.rb:95:in `fetch'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/processor.rb:77:in `process_one'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/processor.rb:68:in `run'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/util.rb:56:in `watchdog'
/var/www/violet/shared/bundle/ruby/2.6.0/gems/sidekiq-6.4.1/lib/sidekiq/util.rb:65:in `block in safe_thread'
-------------------------------
Data:
-------------------------------
* data: {:sidekiq=>{}} I discovered we are not aborting requests correctly, see here: #1434 |
Addresses: #1434 #1419 (comment) Co-authored-by: Pralish Kayastha <50227291+Pralish@users.noreply.github.com>
@@ -0,0 +1,11 @@ | |||
class RackAttackMailer < ApplicationMailer | |||
def limit_exceeded(user, error_limit_exceeded = false) | |||
@user = user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pralish you should CC the email to global admins as well
Deployed review-app can be viewed at https://review-1419.violet-test.net |
Deployed review-app can be viewed at https://review-1419.violet-test.net |
1 similar comment
Deployed review-app can be viewed at https://review-1419.violet-test.net |
@@ -9,4 +9,7 @@ APP_HOST=lvh.me:5250 | |||
RECAPTCHA_SITE_KEY=6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy | |||
RECAPTCHA_SECRET_KEY=6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx | |||
SECRET_KEY_BASE='38c72586473e364229897f24f1892f1dc5565776878aa4d8c6bf051258622bd2e923b926ab59b40f912b661216f764d993e8d6b8bbfbc33026e5c954b6c51f9b' | |||
REQUEST_PER_MINUTE=5 | |||
ERROR_PER_MINUTE=3 | |||
PERIOD_MULTIPLIER=2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pralish could you create a GitHub issue with documentation on how to tune this feature with these 3 variables?
Deployed review-app can be viewed at https://review-1419.violet-test.net |
Addresses: #538