Rack::Attack VS bullet

Compare Rack::Attack vs bullet and see what are their differences.

bullet

help to kill N+1 queries and unused eager loading (by flyerhzm)
Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
Rack::Attack bullet
13 27
5,480 6,984
0.5% -
7.1 7.7
about 2 months ago 3 months ago
Ruby Ruby
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

Rack::Attack

Posts with mentions or reviews of Rack::Attack. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-10-28.
  • Rails Authentication for Compliance
    5 projects | dev.to | 28 Oct 2023
    The first line of defense should be to put rate-limiting on your login endpoints. rack-attack can help with that. I recommend to limit the login attempts to 5 per minute for a username and block the IP for 30 minutes. You should also limit the number of login attempts from the same IP address, but this needs to be adjusted to the application you are working on, because if it is a tool used in classrooms, it might be legit to have 50 logins within a few minutes from the same IP. (I have a few post written about rack-attack)
  • 4 Essential Security Tools To Level Up Your Rails Security
    10 projects | dev.to | 31 May 2023
    Rack::Attack
  • Huginn’s IP keeps getting blocked by Kickstarter
    2 projects | /r/selfhosted | 17 Dec 2022
  • rack/rack-attack: Rack middleware for blocking & throttling
    1 project | /r/ruby | 17 Dec 2022
  • Rack-attack gem setup to protect Rails and Rack apps from bad clients
    1 project | dev.to | 8 Aug 2022
    Rack middleware for blocking & throttling abusive requests. Protect your Rails and Rack apps from bad clients. Rack::Attack lets you quickly decide when to allow, block, and throttle based on the properties of the request. Using this gem you can save your web application from attacks, we can whitelist IPs, Block requests according to requirements, and many more… Install Rack-attack gem: # In your Gemfile gem 'rack-attack' Enter fullscreen mode Exit fullscreen mode Plugging into the application Then tell your ruby web application to use rack-attack as a middleware. # config/application.rb # rack attack middleware config.middleware.use Rack::Attack Enter fullscreen mode Exit fullscreen mode Once you’ve done that, you’ll need to configure it. You can do this by creating the file, config/initializers/rack-attack.rband adding the rules to fit your needs. You can disable it permanently (like for a specific environment) or temporarily (can be helpful for specific test cases) by writing: Usage Safe listing Safelists have the most precedence, so any request matching a safelist would be allowed despite matching any number of blocklists or throttles. safelist_ip(ip_address_string) Rack::Attack.safelist_ip(“5.6.7.8”) Enter fullscreen mode Exit fullscreen mode safelist_ip(ip_subnet_string) Rack::Attack.safelist_ip(“5.6.7.0/24”) Enter fullscreen mode Exit fullscreen mode safelist(name, &block) Name your custom safelist and make your ruby-block argument return a truthy value if you want the request to be allowed, and false otherwise. Blocking blocklist_ip(ip_address_string) Rack::Attack.blocklist_ip(“1.2.3.4”) Enter fullscreen mode Exit fullscreen mode blocklist_ip(ip_subnet_string) Rack::Attack.blocklist_ip(“1.2.0.0/16”) Enter fullscreen mode Exit fullscreen mode blocklist(name, &block) Name your custom blocklist and make your ruby-block argument return a truthy value if you want the request to be blocked, and false otherwise. Throttling *throttle(name, options, &block) *( provide limit and period as options) Throttle state is stored in a configurable cache (which defaults to Rails.cache if present). Name your custom throttle, provide limit and period as options, and make your ruby-block argument return the discriminator. This discriminator is how you tell rack-attack whether you’re limiting per IP address, per user email, or any other. For example, if we want to restrict requests other than defined routes and display a custom error page. Error page: If we want to restrict requests/IP and if the request limit increases then send a reminder mail. For Example, we want to allow only 300 requests per 30 seconds after that will restrict requests from this IP till the next 30 seconds interval starting. Get error mail if the limit is extended. Performance The overhead of running Rack::Attack is typically negligible (a few milliseconds per request), but it depends on how many checks you’ve configured, and how long they take. Throttles usually require a network roundtrip to your cache server(s), so try to keep the number of throttle checks per request low. If a request is blocklisted or throttled, the response is a very simple Rack response. A single typical ruby web server thread can block several hundred requests per second. Sample rack-attack.rb file For more information: https://github.com/rack/rack-attack If this guide has been helpful to you and your team please share it with others!
  • Limiting the amount of calls user can make to an api
    1 project | /r/rails | 11 Nov 2021
    Second vote for rack-attack!
  • Devise and email spam?
    1 project | /r/rails | 4 Nov 2021
    You could use something like Rack Attack to mitigate this type of behavior if it becomes an issue.
  • 10 things I add to every Rails app
    9 projects | dev.to | 2 Oct 2021
    The final gem I like to include in all projects is rack-attack. This is a rate limiting tool which is great for throttling dangerous actions in your app to prevent bot attacks or other malicious users.
  • Rails application boilerplate for fast MVP development
    63 projects | dev.to | 6 Aug 2021
    rack-attack to prevent bruteforce and DDoS attacks
  • How to prevent scraping/copying data?
    1 project | /r/ruby | 23 Jun 2021
    Check out Rack Attack. It lets you block bots that make requests too fast to be real users, or that request obviously-suspect URLs (/phpmyadmin for example). There are lots of other options, but those are the quick wins IMO.

bullet

Posts with mentions or reviews of bullet. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-04-18.
  • What was the name of the gem that finds all unindexed foreign keys?
    3 projects | /r/rails | 18 Apr 2023
  • Ban 1+N in Django
    10 projects | news.ycombinator.com | 26 Mar 2023
    Rails has Bullet[0] to help identify and warn you against N+1

    Does Django have anything active? Quick search revealed nplusone[1] but its been dead since 2018.

    [0] https://github.com/flyerhzm/bullet

    [1] https://github.com/jmcarp/nplusone

  • Inherited rails app - what the hell are all these rack timeout lines in the log?
    2 projects | /r/rails | 19 Jan 2023
    Without seeing more of the app, it's tough to say for certain, but one gem you might find helpful is the [bullet](https://github.com/flyerhzm/bullet) gem -- set this up in the app then start browsing around the app in development. If you have any N+1 queries or other minor optimizations that could be done it will inform you about them.
  • A Guide to Memoization in Ruby
    2 projects | dev.to | 11 Jan 2023
    Getting rid of N+1 queries - This can help improve the speed of an app. The Bullet or Prosopite gems can give a lending hand here. The N+1 Dilemma — Bullet or Prosopite? entails a brief comparison of both.
  • Understanding N and 1 queries problem
    3 projects | news.ycombinator.com | 2 Jan 2023
    There's a Ruby gem called Bullet that identifies and warns developers about N+1 problems. You can also have it fail tests if detected.

    I don't know if the approach is possible with every ORM or if it's just leveraging some Ruby perks, but I can't think of a good reason why you wouldn't use the equivalent everywhere.

    https://github.com/flyerhzm/bullet

  • Help with N+1 problem.
    1 project | /r/rails | 6 Nov 2022
    You might consider adding the bullet gem as a development requirement and see what it tells you, it's generally pretty good at spotting n-queries and letting you know how to fix them.
  • Understanding and Fixing N+1 Query
    1 project | news.ycombinator.com | 2 Oct 2022
    As a Rails developer, recently I found Bullet [0] which helps massively in dealing with eager loading. For some reason I expected the framework to manage this sort of thing for me, even when Rails actually does a ton out of the box already. Only while refactoring I picked up on queries dragging performance. Oh well...

    [0] https://github.com/flyerhzm/bullet

  • How do you find the cause of slowness in your app?
    3 projects | /r/rails | 26 Jul 2022
    This is good advice, it'll likely pick out some glaring issues right away. I would generally recommend looking at DB queries here too and recommend Bullet, but most software like DataDog, AppSignal etc will often also point N+1 and issues like it out.
  • Yet Another Post About N + 1 Queries
    1 project | dev.to | 12 Jul 2022
    In order to find all those N + 1 queries that are slowing down in your application, the community recommends using the Bullet gem.
  • What are the main suspects in a really slow Rails app?
    4 projects | /r/rails | 21 Jun 2022

What are some alternatives?

When comparing Rack::Attack and bullet you can also consider the following projects:

Metasploit - Metasploit Framework

prosopite - :mag: Rails N+1 queries auto-detection with zero false positives / false negatives

Rack::Protection - NOTE: This project has been merged upstream to sinatra/sinatra

rack-mini-profiler - Profiler for your development and production Ruby rack apps.

rspec-rails - RSpec for Rails 6+

Peek - Take a peek into your Rails applications.

Rack::UTF8Sanitizer - Rack::UTF8Sanitizer is a Rack middleware which cleans up invalid UTF8 characters in request URI and headers.

Derailed Benchmarks - Go faster, off the Rails - Benchmarks for your whole Rails app

BeEF - The Browser Exploitation Framework Project

benchmark-ips - Provides iteration per second benchmarking for Ruby

Gitrob - Reconnaissance tool for GitHub organizations

ruby-prof - A ruby profiler. See https://ruby-prof.github.io for more information.