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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Lets build-ruby-app-server: Vineet tyagi

2,579

Published on

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.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,579
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
42
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Let’s build a Ruby Application Server Team WebROaR
  • 2. How do ‘you’ visualize an ‘Application Server’?
  • 3. Or it could be like this …
  • 4. Let’s define the specs
  • 5. Rack Compliant Run all Ruby Web Applications
  • 6. And also ..  Provide run time performance numbers of the deployed applications  Report exceptions
  • 7. Love to have …  Maximum performance  Simplicity
  • 8. Let’s start building it …
  • 9. 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
  • 10. Network Server Design Evented vs Threaded
  • 11. Event Based I/O Libraries  libev (Written in C)  EventMachine (Ruby Module + Extension Library written in C++)
  • 12. HTTP Parser Mongrel’s Ragel Based Parser (written in C) is ‘awesome’
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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; }
  • 17. 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
  • 18. Hola, we got a basic application server ready!
  • 19. The Server – First Cut HTTP Request Rack Web Application libebb Ruby Interpreter Response
  • 20. But it only processes one request at a time ..
  • 21. Let’s split up the server code and create more ruby processing instances & static file renderers (‘workers’)
  • 22. 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
  • 23. Server can handle (very) high load with this architecture
  • 24. Let’s capture data for each request being processed …
  • 25. 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
  • 26. Hurray, we can write all the new advanced features in our favorite language .. 
  • 27. Ruby makes life easier for …  Instrumentation  Messaging  Analyzer  Interacting with the Database  Admin Panel (It’s a Rails Application!)
  • 28. 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
  • 29. Check it out WebROaR – http://webroar.in
  • 30. More Questions?
  • 31. 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

×