Comparative study Ruby & Rails

1.Web server

  1. Unicorn

  2. Unicorn is designed for fast-running requests.

  3. Single-threaded, multi-process甩卓。

  4. All processes listen on a single shared socket, this simplifies reverse proxy configuration

  5. Good stability.

  6. Thin

  7. Allows high concurrency.

  8. Uses the evented I/O model by utilizing the EventMachine library.

  9. Need to monitor crashes etc.

  10. High customization, but it is difficult to design efficient clusters.

  11. Rainbows: based on unicorn, for sleepy apps and slow clients

  12. Puma

  13. Built For Concurrency.

  14. Can change Single-process mode to Multi-process. Single-process, multi-threaded, use Thread Pool.

  15. According to the number of requests to adjust the number of threads between min and max.

  16. Use less resource of RAM when the number of request is small.

  17. Allowing blocking IO to be run concurrentl.

  18. To make best use of multi-CUP, change MRI to JRuby or Rubinius.

  19. Not very good stability.

  20. Passenger(Raptor)

  21. Most Simple config.(Passeger's goal is to make everything Just Work(tm) with as little hassle as possible.)

  22. Integrates directly into Apache or Nginx.

  23. Not easy to customize留潦,advanced features need to pay.

  24. References:

  25. Ruby on Rails Server options

  26. The Philosophy Behind unicorn

  27. Puma README

  28. Ruby multi-threaded server

2.Sidekiq

  1. Simple, efficient background processing for Ruby. In some cases like delivering many emails in one task.

  2. Sidekiq build a page for managing background processes.

  3. Both Resque and Sidekiq are Redis-backed.

  4. Resque forks a new process for every job, Sidekiq uses multithreading.

  5. Use Resque to makes a queue of jobs in Radis then let Sidekiq process them in some particular situations like creating a user firstly and then upload a avatar.

3.Zeus

  1. Speed up rails command execution.

  2. Bugs Issues.

4.Rails vs Sinatra

  1. Rails

    1. Pros
      1. Rails is a integration for web development.
        1. Database access, ActiveRecord.
        2. Template engine, Erb.
        3. Test framwork
        4. Many open-source and high-quality gems.
      2. Use Rails can build a porject very fastly.
  2. Cons

    1. ActiveRecord: Easy to use, but bad design like 1 + N query.
    2. Performance: Rails applications are not as fast as Java or C.
    3. Scaling: it's not easy to optimize and refactor when the project becomes large.
  1. Sintra

    1. Pros

      1. Easy to learn.(Simple wrapper for Rack)
      2. Focus on HTTP.
      3. Good performance compare to Rails.
      4. Easy to work with ruby gems, easy to customize for small web porject.
    2. Cons

      1. Need to draw up a standard for development of Sintra.

      2. Need to do many work for efficient development.

        1. Srcipts doing some work like rails new
        2. Building development, test and production evrionments
        3. Connnecting database.
        4. Loging.
        5. Some thing like rails console
        6. Deploy
        7. Maintain
      3. Hand-over, need readable and overall documents.

  2. How do we make decision on which framework to use坎弯?

  3. It depends on requirements.

  4. Rails:

    1. When we need launch a poject as far as possible for test our new ideas or the feedback from users.
  5. Sinatra:

    1. Help fresher to learn what file structure and components a web server need, for understanding deeply how Rails works.
    2. When a poject needn't do every things a normal web app will, like API server, use Sinatra with good design of project structure and proper gems can make a better performance than Rails.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末仓技,一起剝皮案震驚了整個濱河市戚嗅,隨后出現(xiàn)的幾起案子侥猬,更是在濱河造成了極大的恐慌傀蓉,老刑警劉巖勒叠,帶你破解...
    沈念sama閱讀 218,122評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件兜挨,死亡現(xiàn)場離奇詭異,居然都是意外死亡眯分,警方通過查閱死者的電腦和手機拌汇,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來弊决,“玉大人噪舀,你說我怎么就攤上這事∑” “怎么了与倡?”我有些...
    開封第一講書人閱讀 164,491評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長昆稿。 經(jīng)常有香客問我纺座,道長,這世上最難降的妖魔是什么溉潭? 我笑而不...
    開封第一講書人閱讀 58,636評論 1 293
  • 正文 為了忘掉前任净响,我火速辦了婚禮,結(jié)果婚禮上喳瓣,老公的妹妹穿的比我還像新娘馋贤。我一直安慰自己,他們只是感情好畏陕,可當我...
    茶點故事閱讀 67,676評論 6 392
  • 文/花漫 我一把揭開白布掸掸。 她就那樣靜靜地躺著,像睡著了一般蹭秋。 火紅的嫁衣襯著肌膚如雪扰付。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,541評論 1 305
  • 那天仁讨,我揣著相機與錄音羽莺,去河邊找鬼。 笑死洞豁,一個胖子當著我的面吹牛盐固,可吹牛的內(nèi)容都是我干的荒给。 我是一名探鬼主播,決...
    沈念sama閱讀 40,292評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼刁卜,長吁一口氣:“原來是場噩夢啊……” “哼志电!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蛔趴,我...
    開封第一講書人閱讀 39,211評論 0 276
  • 序言:老撾萬榮一對情侶失蹤挑辆,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后孝情,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體鱼蝉,經(jīng)...
    沈念sama閱讀 45,655評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,846評論 3 336
  • 正文 我和宋清朗相戀三年箫荡,在試婚紗的時候發(fā)現(xiàn)自己被綠了魁亦。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,965評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡羔挡,死狀恐怖洁奈,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情绞灼,我是刑警寧澤利术,帶...
    沈念sama閱讀 35,684評論 5 347
  • 正文 年R本政府宣布,位于F島的核電站镀赌,受9級特大地震影響氯哮,放射性物質(zhì)發(fā)生泄漏际跪。R本人自食惡果不足惜商佛,卻給世界環(huán)境...
    茶點故事閱讀 41,295評論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望姆打。 院中可真熱鬧良姆,春花似錦、人聲如沸幔戏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,894評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽闲延。三九已至痊剖,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間垒玲,已是汗流浹背陆馁。 一陣腳步聲響...
    開封第一講書人閱讀 33,012評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留合愈,地道東北人叮贩。 一個月前我還...
    沈念sama閱讀 48,126評論 3 370
  • 正文 我出身青樓击狮,卻偏偏與公主長得像,于是被迫代替她去往敵國和親益老。 傳聞我的和親對象是個殘疾皇子彪蓬,可洞房花燭夜當晚...
    茶點故事閱讀 44,914評論 2 355

推薦閱讀更多精彩內(nèi)容