Lets build-ruby-app-server: Vineet tyagi
Upcoming SlideShare
Loading in...5
×
 

Lets build-ruby-app-server: Vineet tyagi

on

  • 3,494 views

Would you like to know how to build an application server from scratch? This talk would provide an insight to the thought process and the key decisions made while building WebROaR from grounds up ...

Would you like to know how to build an application server from scratch? This talk would provide an insight to the thought process and the key decisions made while building WebROaR from grounds up using C & Ruby.

What enables this server to deliver high performance and also offer a rich bouquet of integrated features like Analytics, Exception Notifications etc? If gaining knowledge about design of a good software product interests you, do join us for this interactive session.

Statistics

Views

Total Views
3,494
Views on SlideShare
3,482
Embed Views
12

Actions

Likes
2
Downloads
40
Comments
0

2 Embeds 12

http://www.slideshare.net 8
http://lanyrd.com 4

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

Lets build-ruby-app-server: Vineet tyagi Lets build-ruby-app-server: Vineet tyagi Presentation Transcript

  • Let’s build a Ruby Application Server Team WebROaR
  • How do ‘you’ visualize an ‘Application Server’?
  • Or it could be like this …
  • Let’s define the specs
  • Rack Compliant Run all Ruby Web Applications
  • And also ..  Provide run time performance numbers of the deployed applications  Report exceptions
  • Love to have …  Maximum performance  Simplicity
  • Let’s start building it …
  • What does the server need to do? Accept client connection Parse HTTP request Hand it over to the ruby web framework Send its response back to the client
  • Network Server Design Evented vs Threaded
  • Event Based I/O Libraries  libev (Written in C)  EventMachine (Ruby Module + Extension Library written in C++)
  • HTTP Parser Mongrel’s Ragel Based Parser (written in C) is ‘awesome’
  • Server Tasks Options Accept client connection libev/EventMachine Parse HTTP request Mongrel’s Ragel based Parser Hand it over to the ruby web ? framework Send its response back to the libev/EventMachine client
  • More awesomeness - Libebb  Lightweight HTTP Library for C  libev + Mongrel’s Ragel based Parser  Implements HTTP/1.1 Grammar  Supports persistent, pipelined & chunked requests  Rejects invalid and malicious requests
  • Server Tasks Options Accept client connection libebb Parse HTTP request libebb Hand it over to the ruby web ? framework Send its response back to the libebb client
  • Embedded Ruby Interpreter #include <ruby.h> int main(int argc, char **argv) { int state = 0; ruby_init(); ruby_script("c-executable-name"); ruby_init_loadpath(); //Can use rb_gv_set() or rb_iv_set() methods to pass parameters to ruby land rb_protect(RUBY_METHOD_FUNC(rb_require), (VALUE)"path-to-ruby-script", &state); if(state != 0) { // Exception Handling Code return -1; } //Can use rub_funcall() to invoke methods in the ruby land return 0; }
  • Server Tasks Options Accept client connection libebb Parse HTTP request libebb Hand it over to the ruby web Embedded Ruby Interpreter framework Send its response back to the libebb client
  • Hola, we got a basic application server ready!
  • The Server – First Cut HTTP Request Rack Web Application libebb Ruby Interpreter Response
  • But it only processes one request at a time ..
  • Let’s split up the server code and create more ruby processing instances & static file renderers (‘workers’)
  • The more powerful server version … Rack Web Application libev Asynchronous Ruby Interpreter Non-blocking I/O Worker #1 HTTP Request Rack Web Application SCGI libev libebb libev Ruby Interpreter Response Worker #2 Head libev Static Files Renderer Worker #n
  • Server can handle (very) high load with this architecture
  • Let’s capture data for each request being processed …
  • The Server – Current Architecture Message Queue Analyzer Admin Panel Daemon DB Request Analytics Data & Exception Notifications Conf File HTTP Request Worker #1 Head Worker #n Response
  • Hurray, we can write all the new advanced features in our favorite language .. 
  • Ruby makes life easier for …  Instrumentation  Messaging  Analyzer  Interacting with the Database  Admin Panel (It’s a Rails Application!)
  • Takeaways  Use the best tool for the job  C – Network I/O, Ruby – Advanced Features  Do not reinvent the wheel. Use tried and tested libraries
  • Check it out WebROaR – http://webroar.in
  • More Questions?
  • Photo Credits All photographs used in this presentation are licensed under Creative Commons  Slide 3 – Stone House By Jsome1  Slide 5, 34 – Our House By Lee Coursey  Slide 11 – Willow Lane Construction By Lee Coursey  Slide 22 – Construction of our House – Framing By Lee Coursey  Slide 27 – Dead Lift By scarndp  Slide 29 – Willow Lane Construction By Lee Coursey  Slide 35 – Very Happy By Chris Winters  Slide 37 – Lion By auburnxc