Socket
Book a DemoInstallSign in
Socket

rails_api_benchmark

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_api_benchmark

0.2.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

RailsApiBenchmark

Work in progress, you can use it like this, see Important

Usage

Run it with:

rails api:benchmark

Display your configuration with:

rails api:benchmark:config

Example output:

{
  "concurrency": 2,
  "host": "localhost:5000",
  "nb_requests": 1000,
  "results_folder": "benchmark",
  "auth_header": "Authorization: Token token=benchToken",
  "curl_cmd": "curl -H \"%{auth_header}\" http://%{host}%{route}",
  "bench_cmd": "ab -n %{nb_requests} -c %{concurrency} -g plot.tsv -H \"%{auth_header}\" http://%{host}%{route}",
  "server_cmd": "bundle exec puma",
  "env_vars": {
    "RAILS_MAX_THREADS": "2",
    "RAILS_ENV": "production"
  },
  "regexps": [
    {
      "key": "response_time",
      "name": "Average time per request (ms)",
      "regexp": "(?-mix:Time\\s+per\\s+request:\\s+([0-9.]*).*\\(mean\\))"
    },
    {
      "key": "req_per_sec",
      "name": "Requests per second (#)",
      "regexp": "(?-mix:Requests\\s+per\\s+second:\\s+([0-9.]*).*\\(mean\\))"
    }
  ],
  "routes": [
    {
      "name": "candidates_per_25",
      "route": "/candidates",
      "method": "get",
      "title": "GET /candidates",
      "description": "Get first page of candidates (default 25 per page)"
    }
  ]
}

Important

  • Only JSON responses are supported yet
  • Only GET requests are supported yet
  • Configuration is not validated

Installation

  • Install gnuplot
  • Install ApacheBench

For ubuntu:

sudo apt-get install gnuplot
sudo apt-get install apache2-utils
  • Add this line to your application's Gemfile:
gem 'rails_api_benchmark'
  • And then execute:
bundle
  • Provide necessary configuration in initializer, generate it with:
rails g rails_api_benchmark:config
  • Next, add this to your Rakefile:
require 'rails_api_benchmark/benchmark_tasks'

You can now run:

rails api:benchmark

Screenshots

The README is the benchmark index, the page you’ll see in benchmark/ folder. It lists all the routes configured to be benchmarked:

Benchmark Index

Results are listed in a summary table to allow fast-spotting of slowdowns:

Benchmark Summary

Result page for a single route with gnuplot:

Benchmark Results

Contributing

Contributions are welcome

License

The gem is available as open source under the terms of the MIT License.

TODO

  • POST requests handling
  • Add simplecov to permit controller coverage for example
  • Document configuration template file

FAQs

Package last updated on 08 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.