Project

rodent

0.03
No commit activity in last 3 years
No release in over 3 years
Rodent is an open source asynchronous framework for Micro Service Architecture (MSA). It is a lightweight and designed to easily develop APIs. Main goals is scaling, simplicity and perfomance.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.1.1, ~> 1.1
>= 0.6.2, ~> 0.6
>= 10.2.2, ~> 10.2
>= 3.1.1, ~> 3.1
>= 2.14.1, ~> 2.14
>= 0.8.7.3, ~> 0.8

Runtime

>= 1.3.0, ~> 1.3
>= 1.10.0, ~> 1.10
>= 1.0.3, ~> 1.0
>= 1.0.3, ~> 1.0
>= 1.9.2, ~> 1.9
 Project Readme

Rodent

Code Climate Build Status Dependency Status

Rodent is an open source asynchronous framework for Micro Service Architecture (MSA). It is a lightweight and designed to easily develop APIs. Main goals is scaling, simplicity and perfomance.

The framework uses Goliath as HTTP proxy and AMQP protocol to connect MSA for handling requests. Micro Services can be run separately and multiple times for scaling, hot-reloading or language independence. All requests are load balanced with same MSA.

You can learn more about MSA in great article by James Hughes.

Installation & Prerequisites

Rodent is available as a gem, to install it just install the gem

$> gem install rodent

If you're using Bundler, add the gem to Gemfile

gem 'rodent'

Getting Started: Hello World

Proxy server for sending HTTP requests into Micro Service (based on Grape)

# proxy.rb

require 'rodent'
require 'grape'

class CustomersProxy < Grape::API
  version 'v1', using: :path
  format :json
  default_format :json

  resource :customers do
    params do
      requires :name, type: String
      requires :email, type: String
    end
    post '/' do
      header 'Rodent-Proxy', 'customers.create'

      {name: params[:name], email: params[:email]}
    end
  end
end

class ProxyApp < Goliath::API
  plugin Rodent::Goliath::Plugin
  use Rodent::Goliath::Middleware

  def response(env)
    CustomersProxy.call(env)
  end
end

Micro Service for handling requests

# customers.rb

require 'rodent'

class Customer
  attr_accessor :name, :email

  def initialize(options)
    @name = options['name']
    @email = options['email']
  end

  def as_json
    {recipient: [name, ' <', email, '>'].join}
  end
end

class CustomersAPI < Rodent::Base
  listen 'customers.create' do
    self.status = 201

    @customer = Customer.new(params)
    @customer.as_json
  end
end

class CustomersServer < Rodent::Server
  configure do
    set :connection, 'amqp://guest:guest@localhost'
  end

  run do
    Signal.trap('INT') { Rodent::Server.stop }

    [CustomersAPI]
  end
end

Run proxy server

$> ruby proxy.rb -v -s -e development -p 3000

Run micro service

$> ruby customers.rb

Then you can test it

$> curl -X POST localhost:3000/v1/customers -d "name=Bob" -d "email=bob@example.com"

Performance

My results is below

Server Software:        Goliath
Server Hostname:        localhost
Server Port:            3000

Document Path:          /v1/customers
Document Length:        2 bytes

Concurrency Level:      50
Time taken for tests:   2.450 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      126000 bytes
HTML transferred:       2000 bytes
Requests per second:    408.18 [#/sec] (mean)
Time per request:       122.495 [ms] (mean)
Time per request:       2.450 [ms] (mean, across all concurrent requests)
Transfer rate:          50.23 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   1.0      2       5
Processing:    51  118  40.5    116     233
Waiting:       45  116  41.0    115     232
Total:         51  120  40.7    117     235

License & Acknowledgments

Rodent is distributed under the MIT license, for full details please see the LICENSE file.

Bitdeli Badge