Grape golilath
Upcoming SlideShare
Loading in...5
×
 

Grape golilath

on

  • 745 views

Micro-framework for Evented API Servers

Micro-framework for Evented API Servers

Statistics

Views

Total Views
745
Views on SlideShare
745
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Grape golilath Grape golilath Presentation Transcript

    • CONTENTS ● Brief Description on: 1. Grape 2. Goliath 3. Eventmachine 4. Fiber 5. Node.JS 6. Node.JS vs EM ● Grape_Goliath Gem and Usage
    • GRAPE ● REST-like API micro-framework for Ruby ● Designed to run on Rack or complement existing web application frameworks. ● Grape APIs are Rack applications that are created by subclassing Grape::API.
    • Advantages ● No need of rails to create simple API's. ● Grape allows you to build lightweight APIs with Ruby when you don't need the heavy lifting power of large frameworks like Rails.
    • GOLIATH ● Non-blocking Ruby web server ● Serves to requests using a EventMachine loop. ● Uses a Fiber to process a request.
    • Significance of Goliath ● Bare metal performance ● Rack API and middleware support ● Simple configuration ● Fully asynchronous processing ● Readable and maintainable code
    • Goliath Advantage ● Major advantage over other frameworks is that by leveraging Ruby fibers introduced in Ruby 1.9+, it can untangle the complicated callback-based code into a known format. ● Linear execution, leads to more maintainable and readable code.
    • ..contd ● Each HTTP request within Goliath is executed within its own Ruby fiber and all asynchronous I/O operations can transparently suspend and later resume the processing without requiring the developer to write any additional code. ● Both request processing and response processing can be done in fully asynchronous fashion: streaming uploads, firehose API's, request/response, websockets, and so on.
    • Goliath compared to other servers like Thin ● Goliath is able to run on different Ruby platforms. ● It uses a different HTTP parser, supports HTTP keepalive & pipelining. ● Offers a fully asynchronous API for both request and response processing.
    • ..contd ● Goliath claims to works its magic by “leveraging Ruby fibers introduced in Ruby 1.9+”. ● Fibers are primitives for implementing light weight cooperative concurrency in Ruby. Basically they are a means of creating code blocks that can be paused and resumed, much like threads. ● The main difference is that they are never preempted and that the scheduling must be done by the programmer.
    • EVENTMACHINE ● EventMachine is an event-driven I/O and lightweight concurrency library for Ruby. ● It provides event-driven I/O using the Reactor pattern, much like JBoss Netty, Apache MINA, Python's Twisted, Node.js, libevent and libev.
    • EM Significance ● Extremely high scalability, performance and stability for the most demanding production environments. ● An API that eliminates the complexities of high-performance threaded network programming, allowing engineers to concentrate on their application logic. ● This unique combination makes EventMachine a premier choice for critical networked applications, including Web servers and proxies, email and IM production systems, authentication/authorization processors, and many more.
    • EventMachine Usage ● Scalable event-driven servers. Examples: Thin or Goliath. ● Scalable asynchronous clients for various protocols, RESTful APIs and so on. Examples: em-http-request or amqp gem. ● Efficient network proxies with custom logic. Examples: Proxymachine. ● File and network monitoring tools. Examples: eventmachine-tail and logstash.
    • FIBERS ● Primitives for implementing light weight cooperative concurrency in Ruby. ● They are never preempted and that the scheduling must be done by the programmer and not the VM. ● Small 4KB stack enables it to be paused from deeply nested function calls within the fiber block. ● Run using the Fiber#resume method. The code running inside the fiber can give up control by calling Fiber.yield.
    • Client Example
    • Server Example
    • Node.JS vs EM
    • Pros and Cons EM ● Clever DSL ● Also Fast ● Its Ruby ● Mature ● Restricted EM Libraries. ● More difficult to write than normal ruby. Node.JS ● Shared Code betweeen Client and Server. ● Lightning Fast ● Javascript used ● Callback Hell ● Less Mature.
    • EventMachine Better than Node.JS? YES ● EventMachine’s concurrent processing ability is stronger than Node.js 50%. ● When request number goes up, Node.js’s connection rate goes down.
    • Gem Grape_Goliath ● Gem which creates an application with tree structure specified for a Goliath application having Grape API framework. ● Included Gems in tree structure : grape, goliath, em_synchrony ● Added dependencies of rubigen included.
    • Basic tree structure /config
    • Important Gems Used Rubigen ● A framework to allow Ruby applications to generate file/folder stubs. ● RubiGen will be normally integrated into another RubyGem, such as newgem, rails or camping. ● Here we have used newgem. `` NewGem ● Quickly bundle any Ruby libraries into a RubyGem and share it with the world.
    • Generators ● There are two types : 1. Application generators – Used by developers for the framework to get started. Generally used to generate a basic stub directory files/folders. 2. Component generators - Used by developers to extend their application. ● Here we have used application generator for basic goliath app tree structure generation.
    • grape_goliath_generator.rb ● Application generator for the gem. ● Its manifest method includes the directories that are to be created and the files that should be inlcuded in the tree structure. ● The files that should get added with specified code are to be included in the templates folder in the path app/application_generator/grape_goliath /templates.
    • Usage ● grape_goliath application_name ● cd application_name ● bundle install (To install all dependencies) ● ruby server.rb -vs (To run the Goliath server) ● For further info visit: https://github.com/qburstruby/grape_goliath
    • Enjoy Grape_Goliath!! Thank You